我有一个模型用户和另一个模型,其中管理员和用户来自同一模型用户。
admin = models.ForeignKey(User)
users = models.ManyToManyField(User)
我收到此错误:
ERRORS:
admin: (fields.E304) Reverse accessor for 'admin' clashes with reverse accessor for 'users'.
HINT: Add or change a related_name argument to the definition for 'admin' or 'users'.
users: (fields.E304) Reverse accessor for 'users' clashes with reverse accessor for 'admin'.
HINT: Add or change a related_name argument to the definition for 'users' or 'admin'.
答案 0 :(得分:1)
更改此代码:
admin = models.ForeignKey(User, related_name='admin_user')
users = models.ManyToManyField(User, related_name='users_user')
答案 1 :(得分:0)