Hello all,
I have this model:
class Favorite(models.Model):
content_type = models.ForeignKey(ContentType)
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey()
user = models.ForeignKey(User)
created = models.DateTimeField()
class Meta:
# a user can only favorite an object once
unique_together = (("user", "content_type", "object_id"),)
def add_fav(user, object):
ctype = ContentType.objects.get_for_model(object)
fav, created =
DaoFavorite.objects.get_or_create(content_type=ctype,
object_id=object.id, user=user)
add_fav = staticmethod(add_fav)
And calling add_fav( ) I once in a while get IntegrityError: duplicate
key violates unique constraint "splice_daofavorite_user_id_key" which
confuses me quite a bit as I'm using get_or_create...
Anyone got any ideas?
- bram
--~--~---------~--~----~------------~-------~--~----~
You received this message because you are subscribed to the Google Groups
"Django users" group.
To post to this group, send email to [email protected]
To unsubscribe from this group, send email to [EMAIL PROTECTED]
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en
-~----------~----~----~----~------~----~------~--~---