Django-allauth: Server error when deleting User

Created on 10 Mar 2018  路  4Comments  路  Source: pennersr/django-allauth

When trying to delete a user, a error 500 is thrown:

ProgrammingError at /admin/auth/user/
relation "allauth_socialaccount" does not exist
LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "allauth_s...

The app uses the default django user model, no delete signals are being used. No social accounts are setup (email only). Allauth is used in combination with django-rest-framework and django-rest-auth


Traceback:

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/db/backends/utils.py" in _execute
  85.                 return self.cursor.execute(sql, params)

The above exception (relation "allauth_socialaccount" does not exist
LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "allauth_s...
                                                             ^
) was the direct cause of the following exception:

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/core/handlers/exception.py" in inner
  35.             response = get_response(request)

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
  128.                 response = self.process_exception_by_middleware(e, request)

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/core/handlers/base.py" in _get_response
  126.                 response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/contrib/admin/options.py" in wrapper
  574.                 return self.admin_site.admin_view(view)(*args, **kwargs)

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/utils/decorators.py" in _wrapped_view
  142.                     response = view_func(request, *args, **kwargs)

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/views/decorators/cache.py" in _wrapped_view_func
  44.         response = view_func(request, *args, **kwargs)

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/contrib/admin/sites.py" in inner
  223.             return view(request, *args, **kwargs)

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/utils/decorators.py" in _wrapper
  62.             return bound_func(*args, **kwargs)

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/utils/decorators.py" in _wrapped_view
  142.                     response = view_func(request, *args, **kwargs)

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/utils/decorators.py" in bound_func
  58.                 return func.__get__(self, type(self))(*args2, **kwargs2)

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/contrib/admin/options.py" in changelist_view
  1596.                 response = self.response_action(request, queryset=cl.get_queryset(request))

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/contrib/admin/options.py" in response_action
  1330.             response = func(self, request, queryset)

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/contrib/admin/actions.py" in delete_selected
  36.         queryset, opts, request.user, modeladmin.admin_site, using)

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/contrib/admin/utils.py" in get_deleted_objects
  131.     collector.collect(objs)

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/contrib/admin/utils.py" in collect
  195.             return super().collect(objs, source_attr=source_attr, **kwargs)

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/db/models/deletion.py" in collect
  221.                     elif sub_objs:

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/db/models/query.py" in __bool__
  276.         self._fetch_all()

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/db/models/query.py" in _fetch_all
  1179.             self._result_cache = list(self._iterable_class(self))

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/db/models/query.py" in __iter__
  53.         results = compiler.execute_sql(chunked_fetch=self.chunked_fetch, chunk_size=self.chunk_size)

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/db/models/sql/compiler.py" in execute_sql
  1066.             cursor.execute(sql, params)

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/db/backends/utils.py" in execute
  68.         return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/db/backends/utils.py" in _execute_with_wrappers
  77.         return executor(sql, params, many, context)

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/db/backends/utils.py" in _execute
  85.                 return self.cursor.execute(sql, params)

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/db/utils.py" in __exit__
  89.                 raise dj_exc_value.with_traceback(traceback) from exc_value

File "/home/<user>/.virtualenvs/<project>-virtualenv/lib/python3.5/site-packages/django/db/backends/utils.py" in _execute
  85.                 return self.cursor.execute(sql, params)

Exception Type: ProgrammingError at /admin/auth/user/
Exception Value: relation "allauth_socialaccount" does not exist
LINE 1: ...user"."is_active", "auth_user"."date_joined" FROM "allauth_s...

Most helpful comment

@nguerinjr you triggered the solution with your comment, thank you :)

'allauth.socialaccount' is now required (see docs) - adding it to INSTALLED_APPS and running the migrations solves the issue.

All 4 comments

+1 for this. We're facing the same issue.

Same problem here, although I use a custom User model.

Actually, this table is created when you specify the socialaccount on INSTALLED_APPS. However, it's created with a different name (maybe socialaccount_socialaccount, I don't remember now).

I've tried creating a new table with this same structure of "socialaccount_socialaccount" with the "allauth_sociallacount" name. It's a workaround, although I don't know the exact reason it's requiring the table with a different name from the default name it's created in this case.

@nguerinjr you triggered the solution with your comment, thank you :)

'allauth.socialaccount' is now required (see docs) - adding it to INSTALLED_APPS and running the migrations solves the issue.

Yeah @nguerinjr is right. The table is created but is named 'socialaccount_socialaccount' and hence we have the issue.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

dollydagr picture dollydagr  路  4Comments

nordbit picture nordbit  路  5Comments

aliabbas-2012 picture aliabbas-2012  路  6Comments

lukeburden picture lukeburden  路  5Comments

HemantNegi picture HemantNegi  路  5Comments