gpt4 book ai didi

Django Rest Framework 不创建表 authtoken_token

转载 作者:行者123 更新时间:2023-12-03 15:25:18 25 4
gpt4 key购买 nike

我正在尝试设置 Django Rest Framework authtoken,据我了解该表 authtoken_token应该在 makemigrations 之后创建和 migrate .我将 rest_framework 添加到 settings.py :

INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'Site',
'rest_framework',
'rest_framework.authtoken',
'MySQLdb'
]

REST_FRAMEWORK = {
# Use Django's standard `django.contrib.auth` permissions,
# or allow read-only access for unauthenticated users.
'DEFAULT_PERMISSION_CLASSES': [
'rest_framework.permissions.IsAdminUser'
],
'DEFAULT_AUTHENTICATION_CLASSES': (
'rest_framework.authentication.BasicAuthentication',
'rest_framework.authentication.SessionAuthentication',
'rest_framework.authentication.TokenAuthentication',
),
}

迁移命令输出:
'manage.py@MySite > makemigrations Site
"C:\Program Files (x86)\JetBrains\PyCharm 2016.2\bin\runnerw.exe" C:\Python27\python.exe "C:\Program Files (x86)\JetBrains\PyCharm 2016.2\helpers\pycharm\django_manage.py" makemigrations Site "C:/Users/Eric Franzen/PycharmProjects/MySite"
No changes detected in app 'Site'

Process finished with exit code 0
manage.py@MySite > migrate Site
"C:\Program Files (x86)\JetBrains\PyCharm 2016.2\bin\runnerw.exe" C:\Python27\python.exe "C:\Program Files (x86)\JetBrains\PyCharm 2016.2\helpers\pycharm\django_manage.py" migrate Site "C:/Users/Eric Franzen/PycharmProjects/MySite"
Operations to perform:
Apply all migrations: Site
Running migrations:
No migrations to apply.

进程以退出代码 0' 结束
如果有人知道为什么没有创建表格,我们将不胜感激!

最佳答案

运行 migrate authtoken修复了这个

关于Django Rest Framework 不创建表 authtoken_token,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/38982290/

25 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com