简体   繁体   中英

Django all-auth testing error - django.db.utils.OperationalError: no such table: socialaccount_openidstore

can anyone help with this Django allauth issue? I'm running Django 1.8 with Python 3 in a virtualenv. I've got allauth installed and working OK in my project but I get an error message when I try and run any tests. Here is the simplest replication of the error I can get:

I create a new project, then download the django-allauth .zip file and copy the allauth directory into my project directory. I add the following apps to INSTALLED_APPS in settings:

'django.contrib.sites',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',

then run python manage.py migrate . So far so good, but when I run python manage.py test I get the following error:

Traceback (most recent call last):
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/db/backends/sqlite3/base.py", line 318, in execute
    return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: no such table: socialaccount_openidstore

The above exception was the direct cause of the following exception:

Traceback (most recent call last):
  File "./manage.py", line 10, in <module>
    execute_from_command_line(sys.argv)
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/core/management/__init__.py", line 338, in execute_from_command_line
    utility.execute()
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/core/management/__init__.py", line 330, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/core/management/commands/test.py", line 30, in run_from_argv
    super(Command, self).run_from_argv(argv)
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/core/management/base.py", line 390, in run_from_argv
    self.execute(*args, **cmd_options)
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/core/management/commands/test.py", line 74, in execute
    super(Command, self).execute(*args, **options)
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/core/management/base.py", line 441, in execute
    output = self.handle(*args, **options)
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/core/management/commands/test.py", line 90, in handle
    failures = test_runner.run_tests(test_labels)
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/test/runner.py", line 210, in run_tests
    old_config = self.setup_databases()
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/test/runner.py", line 166, in setup_databases
    **kwargs
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/test/runner.py", line 370, in setup_databases
    serialize=connection.settings_dict.get("TEST", {}).get("SERIALIZE", True),
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/db/backends/base/creation.py", line 376, in create_test_db
    self.connection._test_serialized_contents = self.serialize_db_to_string()
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/db/backends/base/creation.py", line 413, in serialize_db_to_string
    serializers.serialize("json", get_objects(), indent=None, stream=out)
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/core/serializers/__init__.py", line 129, in serialize
    s.serialize(queryset, **options)
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/core/serializers/base.py", line 52, in serialize
    for obj in queryset:
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/db/backends/base/creation.py", line 409, in get_objects
    for obj in queryset.iterator():
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/db/models/query.py", line 238, in iterator
    results = compiler.execute_sql()
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 829, in execute_sql
    cursor.execute(sql, params)
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/db/utils.py", line 97, in __exit__
    six.reraise(dj_exc_type, dj_exc_value, traceback)
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/utils/six.py", line 658, in reraise
    raise value.with_traceback(tb)
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/db/backends/utils.py", line 64, in execute
    return self.cursor.execute(sql, params)
  File "/Users/AGG/Dropbox/env/lib/python3.4/site-packages/django/db/backends/sqlite3/base.py", line 318, in execute
    return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: socialaccount_openidstore

I've tried deleting the database or project and starting again. I can't find this issue elsewhere on StackOverflow. Extra information: the error goes away if I delete the tests files in allauth or comment out 'allauth.socialaccount' in INSTALLED_APPS. I'm very confused about the "openidstore" table - is it something to do with the migrations in allauth/socialaccount/providers/openid?

  1. Add 'allauth.socialaccount.providers.openid' to INSTALLED_APPS
  2. manage.py makemigrations
  3. manage.py migrate

That solved it for me.

I've succeeded with these lines to INSTALLED_APPS.

'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.openid',

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM