Django syncdb error: one or more models were not checked

/ MySite / project4

class notes(models.Model): created_by = models.ForeignKey(User) detail = models.ForeignKey(Details) 

Details and User are in the same module ie, / mysite / project1 In Models Project1 I defined

  class User(): ...... class Details(): ...... 

When DB I sync, error message appears

Error: One or more models did not validate: project4: Accessor for field 'detail' clashes with related field . Add a related_name argument to the definition for 'detail'.

How can this be solved ..

thanks..

+6
python django django-models django-views
source share
1 answer

We just got it; and I answered ...

You have several foreign keys that django cannot generate unique names for.

You can help by adding the "related_name" arguments to the definitions of foreignkey fields in your models. For example:

  class notes(models.Model): created_by = models.ForeignKey(User, related_name="note_created_by_user") detail = models.ForeignKey(Details, related_name="noted_and_detailed") 

See here for more details. http://docs.djangoproject.com/en/dev/ref/models/fields/#django.db.models.ForeignKey.related_name

+8
source share

All Articles