RuntimeError: Model class users.models.UserProfile doesn't declare an explicit app_label and ...

Django啓動的時候報錯python

File "/home/hehecat/PycharmProjects/MxShop/MxShop/urls.py", line 23, in <module> from users.views import UserViewSet File "/home/hehecat/PycharmProjects/MxShop/apps/users/views.py", line 13, in <module> from users.models import EmailVerifyCode File "/home/hehecat/PycharmProjects/MxShop/apps/users/models.py", line 8, in <module> class UserProfile(AbstractUser): File "/home/hehecat/anaconda3/envs/restful/lib/python3.6/site-packages/django/db/models/base.py", line 118, in new "INSTALLED_APPS." % (module, name) RuntimeError: Model class users.models.UserProfile doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.django

users的model沒法正確引入restful

根據提示去setting中的INSTALLED_APPS 看看app

INSTALLED_APPS = [
...
'users.apps.UsersConfig',
...
]

'users.apps.UsersConfig' 直接修改成‘users’,正確url

那就是apps.UsersConfig有問題了rest

users/apps.pycode

class UsersConfig(AppConfig):
    name = 'app.users'
    verbose_name = '用戶'

name修改name = 'users'爲便可ci

相關文章
相關標籤/搜索