Skip to content

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP

Loading…

Deleting user fails because of nonexistent table #120

Closed
vlinhart opened this Issue · 5 comments

4 participants

@vlinhart

Hi,

I've enabled only facebook integration in django-socialregistration
INSTALLED_APPS = [
'socialregistration',
'socialregistration.contrib.facebook',
]

When trying to delete any user, not even created by django-socialregistration
exception is raised. 'linkedin_linkedinprofile' table is missing which is true,
but shouldn't be necessary.

Traceback (most recent call last):

File "/home/denikditete/env/lib/python2.6/site-packages/django/core/handlers/base.py", line 111, in get_response
response = callback(request, callback_args, *callback_kwargs)

File "/home/denikditete/env/lib/python2.6/site-packages/django/contrib/admin/options.py", line 307, in wrapper
return self.admin_site.admin_view(view)(args, *kwargs)

File "/home/denikditete/env/lib/python2.6/site-packages/django/utils/decorators.py", line 93, in _wrapped_view
response = view_func(request, args, *kwargs)

File "/home/denikditete/env/lib/python2.6/site-packages/django/views/decorators/cache.py", line 79, in _wrapped_view_func
response = view_func(request, args, *kwargs)

File "/home/denikditete/env/lib/python2.6/site-packages/django/contrib/admin/sites.py", line 197, in inner
return view(request, args, *kwargs)

File "/home/denikditete/env/lib/python2.6/site-packages/django/utils/decorators.py", line 28, in _wrapper
return bound_func(args, *kwargs)

File "/home/denikditete/env/lib/python2.6/site-packages/django/utils/decorators.py", line 93, in _wrapped_view
response = view_func(request, args, *kwargs)

File "/home/denikditete/env/lib/python2.6/site-packages/django/utils/decorators.py", line 24, in bound_func
return func(self, args2, *kwargs2)

File "/home/denikditete/env/lib/python2.6/site-packages/django/contrib/admin/options.py", line 1079, in changelist_view
response = self.response_action(request, queryset=cl.get_query_set())

File "/home/denikditete/env/lib/python2.6/site-packages/django/contrib/admin/options.py", line 836, in response_action
response = func(self, request, queryset)

File "/home/denikditete/env/lib/python2.6/site-packages/django/contrib/admin/actions.py", line 36, in delete_selected
queryset, opts, request.user, modeladmin.admin_site, using)

File "/home/denikditete/env/lib/python2.6/site-packages/django/contrib/admin/util.py", line 76, in get_deleted_objects
collector.collect(objs)

File "/home/denikditete/env/lib/python2.6/site-packages/django/contrib/admin/util.py", line 127, in collect
return super(NestedObjects, self).collect(objs, source_attr=source_attr, **kwargs)

File "/home/denikditete/env/lib/python2.6/site-packages/django/db/models/deletion.py", line 168, in collect
if not sub_objs:

File "/home/denikditete/env/lib/python2.6/site-packages/django/db/models/query.py", line 113, in nonzero
iter(self).next()

File "/home/denikditete/env/lib/python2.6/site-packages/django/db/models/query.py", line 107, in _result_iter
self._fill_cache()

File "/home/denikditete/env/lib/python2.6/site-packages/django/db/models/query.py", line 772, in _fill_cache
self._result_cache.append(self._iter.next())

File "/home/denikditete/env/lib/python2.6/site-packages/django/db/models/query.py", line 273, in iterator
for row in compiler.results_iter():

File "/home/denikditete/env/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 680, in results_iter
for rows in self.execute_sql(MULTI):

File "/home/denikditete/env/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 735, in execute_sql
cursor.execute(sql, params)

File "/home/denikditete/env/lib/python2.6/site-packages/django/db/backends/mysql/base.py", line 86, in execute
return self.cursor.execute(query, args)

File "/home/denikditete/env/lib/python2.6/site-packages/MySQLdb/cursors.py", line 174, in execute
self.errorhandler(self, exc, value)

File "/home/denikditete/env/lib/python2.6/site-packages/MySQLdb/connections.py", line 36, in defaulterrorhandler
raise errorclass, errorvalue

DatabaseError: (1146, "Table 'denikditete.linkedin_linkedinprofile' doesn't exist")

GET:,
POST:,
COOKIES:{'__utma': '42635824.1949448190.1309441057.1319877514.1319898991.107',

@flashingpumpkin

Not sure what is going on. Can you confirm this happens too from shell?

@mixman

I get this too on a fresh setup. Seems the models leak into existence.

Problem seems to be AUTHENTICATION_BACKEND 'socialregistration.contrib.facebook.auth.FacebookAuth', that when in use, even when nothing of socialregistration in INSTALLED_APPS causes all the models to be registered.

ERROR: test_management_command (registration.tests.models.RegistrationModelTests)
...
File "/project/ext/registration/management/commands/cleanupregistration.py", line 19, in handle_noargs
RegistrationProfile.objects.delete_expired_users()
File "/project/ext/registration/models.py", line 147, in delete_expired_users
user.delete()
...
DatabaseError: no such table: linkedin_linkedinprofile

@flashingpumpkin

Aye. Will investigate further as soon as I get a couple of mins

@vlinhart

yes, this happens in console as well:

User.objects.get(pk=5)

u = User.objects.get(pk=5)
u.delete()
Traceback (most recent call last):
File "", line 1, in
File "/home/vlinhart/work/denikditete/env/lib/python2.6/site-packages/django/db/models/base.py", line 580, in delete
collector.collect([self])
File "/home/vlinhart/work/denikditete/env/lib/python2.6/site-packages/django/db/models/deletion.py", line 168, in collect
if not sub_objs:
File "/home/vlinhart/work/denikditete/env/lib/python2.6/site-packages/django/db/models/query.py", line 113, in nonzero
iter(self).next()
File "/home/vlinhart/work/denikditete/env/lib/python2.6/site-packages/django/db/models/query.py", line 107, in _result_iter
self._fill_cache()
File "/home/vlinhart/work/denikditete/env/lib/python2.6/site-packages/django/db/models/query.py", line 772, in _fill_cache
self._result_cache.append(self._iter.next())
File "/home/vlinhart/work/denikditete/env/lib/python2.6/site-packages/django/db/models/query.py", line 273, in iterator
for row in compiler.results_iter():
File "/home/vlinhart/work/denikditete/env/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 680, in results_iter
for rows in self.execute_sql(MULTI):
File "/home/vlinhart/work/denikditete/env/lib/python2.6/site-packages/django/db/models/sql/compiler.py", line 735, in execute_sql
cursor.execute(sql, params)
File "/home/vlinhart/work/denikditete/env/lib/python2.6/site-packages/django/db/backends/util.py", line 34, in execute
return self.cursor.execute(sql, params)
File "/home/vlinhart/work/denikditete/env/lib/python2.6/site-packages/django/db/backends/sqlite3/base.py", line 234, in execute
return Database.Cursor.execute(self, query, params)
DatabaseError: no such table: linkedin_linkedinprofile

@amosson

This is due to the import of all the individual contrib backend's Profile Objects in socialregistration.models

Django ends up adding _set fields on the User object which breaks with the table not found error when delete is called.

This pull request fixes it

#128

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Something went wrong with that request. Please try again.