当我尝试托管我的网络应用时,我明白了:
(workout) sahands-mbp:workout sahandzarrinkoub$ python manage.py runserver
Performing system checks...
Unhandled exception in thread started by <function check_errors.<locals>.wrapper at 0x10ce3b950>
Traceback (most recent call last):
File "/Users/sahandzarrinkoub/Documents/Programming/Web/Django/workout/lib/python3.6/site-packages/django/utils/autoreload.py", line 228, in wrapper
fn(*args, **kwargs)
File "/Users/sahandzarrinkoub/Documents/Programming/Web/Django/workout/lib/python3.6/site-packages/django/core/management/commands/runserver.py", line 125, in inner_run
self.check(display_num_errors=True)
File "/Users/sahandzarrinkoub/Documents/Programming/Web/Django/workout/lib/python3.6/site-packages/django/core/management/base.py", line 405, in check
raise SystemCheckError(msg)
django.core.management.base.SystemCheckError: SystemCheckError: System check identified some issues:
ERRORS:
auth.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.
HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.
auth.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.
workoutcal.User.groups: (fields.E304) Reverse accessor for 'User.groups' clashes with reverse accessor for 'User.groups'.
HINT: Add or change a related_name argument to the definition for 'User.groups' or 'User.groups'.
workoutcal.User.user_permissions: (fields.E304) Reverse accessor for 'User.user_permissions' clashes with reverse accessor for 'User.user_permissions'.
HINT: Add or change a related_name argument to the definition for 'User.user_permissions' or 'User.user_permissions'.
System check identified 4 issues (0 silenced).
我无法解释此错误消息,因为它看起来不像普通的python错误消息。在我收到此错误之前,我正在尝试从应用程序中删除sql表,以及自定义默认的Django User模型。这可能是导致错误的原因吗?我该如何解决呢?
更新
我的 models.py :
中包含此代码class User(AbstractUser):
pass
当我删除它时,错误消失了。我不知道为什么。
答案 0 :(得分:1)
您是否按照docs?
中的步骤操作不要忘记将AUTH_USER_MODEL指向它。在创建之前执行此操作 任何迁移或第一次运行manage.py迁移。
此外,在应用程序的admin.py中注册模型:
from django.contrib import admin
from django.contrib.auth.admin import UserAdmin
from .models import User
admin.site.register(User, UserAdmin)