Opened 18 years ago

Closed 18 years ago

Last modified 18 years ago

#2286 closed defect (invalid)

Validation error with syncdb

Reported by: Chris Beaven Owned by: Adrian Holovaty
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: no UI/UX: no

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 by Malcolm Tredinnick, 18 years ago

Resolution: invalid
Status: newclosed

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 by Chris Beaven, 18 years ago

Thanks for that clarification

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