Monday, January 30, 2017

primary key, foreign key combination

When I try to update_or_create model object with primary key that is also a foreign key in some other model I get DoesNotExist error and then IntegrityError duplicate entry error. My way around this is to try get the object and then update it without the primary key or create it (with primary key of course) on exception. Is it a bug or am i doing something wrong?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/2e8fcef0-1662-4ad8-b7dd-31b58447170b%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment