Django 使用allauth报错 RuntimeError: Model class django.contrib.sites.models.Site doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS

一:报错 RuntimeError: Model class django.contrib.sites.models.Site doesn‘t declare an explicit app_label and isn‘t in an application in INSTALLED_APPS

出现这种情况需将Django的Sites框架添加到您的应用程序中,并在您的设置中将SITE_ID设置为1即可。位置放在默认配置的后面,其他应用的前面。

INSTALLED_APPS = [
    django.contrib.admin,
    django.contrib.auth,
    django.contrib.contenttypes,
    django.contrib.sessions,
    django.contrib.messages,
    django.contrib.staticfiles,
    django.contrib.sites,#这边是allauth的依赖包,必须在app和登录模块前面

    xproject,

    #登录模块
    allauth,
    allauth.account,
    allauth.socialaccount,
    allauth.socialaccount.providers.github,

]

SITE_ID = 1

 

二:

报错(‘42S02‘, "[42S02] [Microsoft][ODBC Driver 17 for SQL Server][SQL Server]对象名 ‘django_site‘ 无效。 (208)

这种情况需要同步一下数据库

执行 python manage.py makemigrations

  python manage.py migrate

Django 使用allauth报错 RuntimeError: Model class django.contrib.sites.models.Site doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS

上一篇:汇编语言(一)


下一篇:Django应用之content type(app应用之一django.contrib.contenttypes)