Warning: file_get_contents(/data/phpspider/zhask/data//catemap/2/python/304.json): failed to open stream: No such file or directory in /data/phpspider/zhask/libs/function.php on line 167

Warning: Invalid argument supplied for foreach() in /data/phpspider/zhask/libs/tag.function.php on line 1116

Notice: Undefined index: in /data/phpspider/zhask/libs/function.php on line 180

Warning: array_chunk() expects parameter 1 to be array, null given in /data/phpspider/zhask/libs/function.php on line 181
python social auth带有django错误和;没有这样的表格:app“u customuser”;_Python_Django_Oauth_Openid_Django Authentication - Fatal编程技术网

python social auth带有django错误和;没有这样的表格:app“u customuser”;

python social auth带有django错误和;没有这样的表格:app“u customuser”;,python,django,oauth,openid,django-authentication,Python,Django,Oauth,Openid,Django Authentication,我正在尝试使用示例登录twitter twitter端可以通过twitter将我的信息重定向到 我要去哪里 在/complete/twitter处出现操作错误/ 没有这样的表:app\u customuser 环境: Request Method: GET Request URL: http://127.0.0.1:8000/complete/twitter/?redirect_state=BLa0NTd6yUIEa47Aa0GimQJs8DK7iFg3&oauth_token=vj8S

我正在尝试使用示例登录twitter

twitter端可以通过twitter将我的信息重定向到 我要去哪里

在/complete/twitter处出现操作错误/ 没有这样的表:app\u customuser

环境:

Request Method: GET
Request URL: http://127.0.0.1:8000/complete/twitter/?redirect_state=BLa0NTd6yUIEa47Aa0GimQJs8DK7iFg3&oauth_token=vj8STgAAAAAAkXlhAAABUuA6ldA&oauth_verifier=gUDxqTwS20PRPUlgDEQ3QN7T237qUdAR

Django Version: 1.9.2
Python Version: 2.7.9
Installed Applications:
('django.contrib.auth',
 'django.contrib.admin',
 'django.contrib.contenttypes',
 'django.contrib.sessions',
 'django.contrib.sites',
 'django.contrib.messages',
 'django.contrib.staticfiles',
 'social.apps.django_app.default',
 'example.app')
Installed Middleware:
('django.middleware.common.CommonMiddleware',
 'django.contrib.sessions.middleware.SessionMiddleware',
 'django.middleware.csrf.CsrfViewMiddleware',
 'django.contrib.auth.middleware.AuthenticationMiddleware',
 'django.contrib.messages.middleware.MessageMiddleware')



Traceback:

File "/home/bob/.local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  149.                     response = self.process_exception_by_middleware(e, request)

File "/home/bob/.local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
  147.                     response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/bob/.local/lib/python2.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  57.         response = view_func(request, *args, **kwargs)

File "/home/bob/.local/lib/python2.7/site-packages/django/views/decorators/csrf.py" in wrapped_view
  58.         return view_func(*args, **kwargs)

File "../../social/apps/django_app/utils.py" in wrapper
  51.             return func(request, backend, *args, **kwargs)

File "../../social/apps/django_app/views.py" in complete
  28.                        redirect_name=REDIRECT_FIELD_NAME, *args, **kwargs)

File "../../social/actions.py" in do_complete
  43.         user = backend.complete(user=user, *args, **kwargs)

File "../../social/backends/base.py" in complete
  41.         return self.auth_complete(*args, **kwargs)

File "../../social/utils.py" in wrapper
  229.             return func(*args, **kwargs)

File "../../social/backends/oauth.py" in auth_complete
  182.         return self.do_auth(access_token, *args, **kwargs)

File "../../social/utils.py" in wrapper
  229.             return func(*args, **kwargs)

File "../../social/backends/oauth.py" in do_auth
  193.         return self.strategy.authenticate(*args, **kwargs)

File "../../social/strategies/django_strategy.py" in authenticate
  96.         return authenticate(*args, **kwargs)

File "/home/bob/.local/lib/python2.7/site-packages/django/contrib/auth/__init__.py" in authenticate
  74.             user = backend.authenticate(**credentials)

File "../../social/backends/base.py" in authenticate
  82.         return self.pipeline(pipeline, *args, **kwargs)

File "../../social/backends/base.py" in pipeline
  85.         out = self.run_pipeline(pipeline, pipeline_index, *args, **kwargs)

File "../../social/backends/base.py" in run_pipeline
  112.             result = func(*args, **out) or {}

File "../../social/pipeline/social_auth.py" in social_user
  20.     social = backend.strategy.storage.user.get_social_auth(provider, uid)

File "../../social/apps/django_app/default/models.py" in get_social_auth
  48.                                                           uid=uid)

File "/home/bob/.local/lib/python2.7/site-packages/django/db/models/query.py" in get
  381.         num = len(clone)

File "/home/bob/.local/lib/python2.7/site-packages/django/db/models/query.py" in __len__
  240.         self._fetch_all()

File "/home/bob/.local/lib/python2.7/site-packages/django/db/models/query.py" in _fetch_all
  1074.             self._result_cache = list(self.iterator())

File "/home/bob/.local/lib/python2.7/site-packages/django/db/models/query.py" in __iter__
  52.         results = compiler.execute_sql()

File "/home/bob/.local/lib/python2.7/site-packages/django/db/models/sql/compiler.py" in execute_sql
  848.             cursor.execute(sql, params)

File "/home/bob/.local/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
  79.             return super(CursorDebugWrapper, self).execute(sql, params)

File "/home/bob/.local/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
  64.                 return self.cursor.execute(sql, params)

File "/home/bob/.local/lib/python2.7/site-packages/django/db/utils.py" in __exit__
  95.                 six.reraise(dj_exc_type, dj_exc_value, traceback)

File "/home/bob/.local/lib/python2.7/site-packages/django/db/backends/utils.py" in execute
  64.                 return self.cursor.execute(sql, params)

File "/home/bob/.local/lib/python2.7/site-packages/django/db/backends/sqlite3/base.py" in execute
  323.         return Database.Cursor.execute(self, query, params)

Exception Type: OperationalError at /complete/twitter/
Exception Value: no such table: app_customuser

不知道这是怎么回事。

您似乎在
example/app/models.py
中创建了
类CustomUser(models.Model)
,但尚未迁移您的更改。
因此,如果是这样,您需要运行
python manage.py makemigrations
,然后运行
python manage.py migrate

,我已经通过在
makemigrations
命令中指定
app
实现了这一点。请尝试:

(env)$ python manage.py makemigrations app

Migrations for 'app':
    0001_initial.py:
        - Create model CustomUser

(env)$ python manage.py migrate

Operations to perform:
    Apply all migrations: app, admin, sites, default, sessions, auth, contenttypes
Running migrations:
    Rendering model states... DONE
    Applying app.0001_initial... OK

对于新的
应用程序
,您需要
迁移
新型号

尝试
python manage.py迁移应用程序
,然后尝试
python manage.py makemigrations应用程序


这应该可以工作。

已经尝试过了,python manage.py makemigrations说“未检测到任何更改”。@Moonwalker尝试将
'example.app'
替换为
安装的应用程序
设置.py
文件中的
应用程序,然后运行迁移。不,它找不到没有“example.app”的“应用程序”