python-social-auth with django errors with & ldquo; no table of this type: app_customuser & rdquo;

advertisements

I'm trying to log-in with twitter using example https://github.com/omab/python-social-auth/tree/master/examples/django_example

The twitter side goes fine with twitter redirecting my into http://127.0.0.1:8000/complete/twitter where I'm getting

OperationalError at /complete/twitter/ no such table: app_customuser

Environment:

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

Have no idea what's going on with this one.


I've managed to make this work by specifying app within makemigrations command. Please try:

(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