Skip to content

Instantly share code, notes, and snippets.

@bmispelon
Created December 4, 2012 09:58
Show Gist options
  • Select an option

  • Save bmispelon/4202313 to your computer and use it in GitHub Desktop.

Select an option

Save bmispelon/4202313 to your computer and use it in GitHub Desktop.
potential django bug
# found by frequant on #django
class BaseRatingModel(models.Model):
"""
Base rating model
"""
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey()
user = models.ForeignKey(settings.AUTH_USER_MODEL)
class Meta:
abstract = True
unique_together = (('content_type', 'object_id', 'user'),)
class Helpful(BaseRatingModel):
"""
Model for registering helpful votes
"""
rating = models.SmallIntegerField(_('helpful'), choices=CHOICES)
# Then, if I create two Helpful objects for the same content_object, no errors are thrown
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment