我尝试在Django中创建一个用户和追随者关系,如下所示
id | user_id | follower_id
1 | 20 | 45
2 | 20 | 53
3 | 32 | 20
为此,我做了以下工作:
^{pr2}$其中User
是django.contrib.auth.models.User
模型。在运行makemigrations
时,我得到以下错误:
ERRORS:
AppName.UserFollower.follower_id: (fields.E304) Reverse accessor for 'UserFollower.follower_id' clashes with reverse accessor for 'UserFollower.user_id'.
HINT: Add or change a related_name argument to the definition for 'UserFollower.follower_id' or 'UserFollower.user_id'.
AppName.UserFollower.user_id: (fields.E304) Reverse accessor for 'UserFollower.user_id' clashes with reverse accessor for 'UserFollower.follower_id'.
HINT: Add or change a related_name argument to the definition for 'UserFollower.user_id' or 'UserFollower.follower_id'.
我的问题是,为什么这是错误的?我该怎么解决这个问题?在
您需要添加
related_name
为什么这样
所以,你可以在django docs阅读更多
相关问题 更多 >
编程相关推荐