Django error message “Add a related_name argument to the definition”

前端 未结 8 1485
伪装坚强ぢ
伪装坚强ぢ 2020-12-01 00:53
D:\\zjm_code\\basic_project>python manage.py syncdb
Error: One or more models did not validate:
topics.topic: Accessor for field \'content_type\' clashes with rel         


        
8条回答
  •  栀梦
    栀梦 (楼主)
    2020-12-01 01:25

    You have a number of foreign keys which django is unable to generate unique names for.

    You can help out by adding "related_name" arguments to the foreignkey field definitions in your models. Eg:

    content_type = ForeignKey(Topic, related_name='topic_content_type')
    

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

提交回复
热议问题