Django Rest Framework未创建表authtoken_token [英] Django Rest Framework not creating table authtoken_token

查看:237
本文介绍了Django Rest Framework未创建表authtoken_token的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试设置Django Rest Framework身份验证令牌,据我了解,表 authtoken_token 应该在 makemigrations 和迁移。我在 settings.py 中添加了rest_framework:

Im trying to set up Django Rest Framework authtoken, From what I understand the table authtoken_token should be created after makemigrations and migrate. I added rest_framework to 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'
如果有人知道为什么不使用该表被创建的信息将不胜感激!

Process finished with exit code 0' If anyone has any idea why the table is not being created the information would be appreciated!

推荐答案

运行 migrate authtoken 已修复这个

这篇关于Django Rest Framework未创建表authtoken_token的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆