无法在设置中添加JWT_AUTH

时间:2017-09-05 05:02:53

标签: django django-rest-framework jwt

我想设置JWT令牌的有效期,所以我在settings.py

上添加了这个
JWT_AUTH = {
    'JWT_EXPIRATION_DELTA': datetime.timedelta(days=30),
}

我在设置中添加后,我收到此错误

django.contrib.sites.models.Site doesn't declare an explicit app_label and isn't in an application in INSTALLED_APPS.

' JWT_AUTH'有什么问题?这些是settings.py

的相关部分
INSTALLED_APPS = [
    'corsheaders',
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'django.contrib.sites',
    'allauth',
    'allauth.account',
    'rest_auth.registration',
    'rest_framework',
    'rest_framework.authtoken',
    'rest_auth',
    'profiles',
    'allauth.socialaccount',
    'allauth.socialaccount.providers.facebook',
]
# localhost:8000/
SITE_ID = 9

1 个答案:

答案 0 :(得分:1)

显然,settings.py中任何未解析的引用都会导致Site模型错误,而不会导致settings.py中的名称错误。

虽然在现货Django(customMenu.LoadMenu(IDR_MAINFRAME); customMenu.ChangeToOwnerDraw(customMenu, *m_MenuProperties); m_pMainWnd->SetMenu(&customMenu); )中没有发生这种情况:

  

'foo':datetime.timedelta(days = 3),

     

NameError:未定义名称“datetime”

DRF确实存在一些可能导致此行为的设置错误。