Skip to content

Self Many2Many Relationship duplicate key value violates unique constraint #13

@simone

Description

@simone

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.

Metadata

Metadata

Assignees

No one assigned

    Labels

    No labels
    No labels

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions