simone / django-compositekey

Django Composite Multiple PrimaryKey
77 stars 16 forks source link

Self Many2Many Relationship duplicate key value violates unique constraint #13

Open simone opened 12 years ago

simone commented 12 years ago

In the testapp example, Author.friends doesn't permit to relate an author with himself.

Classic Author (with no CFP) works.

Observation: MayToMany in django assume that symmetrical=True, I think there is an check in the django code for this unique constraint to evolve for the composite keys.

this is the exception:

IntegrityError at /admin/sample/author/'Simone'-'33'/ duplicate key value violates unique constraint "sample_author_friends_from_author_name_from_author_age_to_a_key" DETAIL: Key (from_author_name, from_author_age, to_author_name, to_author_age)=(Simone, 33, Simone, 33) already exists.