Opened 9 years ago

Closed 9 years ago

Last modified 9 years ago

#2286 closed defect (invalid)

Validation error with syncdb

Reported by: SmileyChris Owned by: adrian
Component: Core (Management commands) Version:
Severity: normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: UI/UX:

Description

I have an Email model linked to a Contact model (contact=ForeignKey(Contact) in the Email model).

The Contact model has an EmailField named email.

Syncdb is complaining that:

Reverse query name for field 'contact' clashes with field 'Contact.email'."

If my understanding is correct, the reverse query name will be email_set, not email so this shouldn't be a clash, should it? My work around at the moment is to actually set reverse_query='email_set', syncdb stops complaining but this is (in my understanding) the default reverse query name in this case anyway so it's a bit weird.

(Just to be clear, the Email model is an actual email and the email field is an email address so they do serve seperate purposes)

Change History (2)

comment:1 Changed 9 years ago by mtredinnick

  • Resolution set to invalid
  • Status changed from new to closed

This error message is correct. The email_set attribute you are thinking of is called an "accessor" inside Django and is used for looking up the reverse relation as an attribute on an instance. The reverse query name is used in filter statements for example. See http://www.djangoproject.com/documentation/db_api/#lookups-that-span-relationships. By default, the lowercase name of the related model is used, but in cases like yours, this won't work.

comment:2 Changed 9 years ago by SmileyChris

Thanks for that clarification

Note: See TracTickets for help on using tickets.
Back to Top