Opened 6 years ago

Closed 6 years ago

#30008 closed Bug (duplicate)

OperationalError Thrown On Admin Page While Modifying Data

Reported by: Hansheng Zhao Owned by: nobody
Component: Uncategorized Version: 2.1
Severity: Normal Keywords:
Cc: Triage Stage: Unreviewed
Has patch: no Needs documentation: no
Needs tests: no Patch needs improvement: no
Easy pickings: no UI/UX: no

Description

Environment
System: Mac OS Version 10.13.6
Python: Python 3.7.1 [via Homebrew]
Django: Django 2.1.3/2.1.4

Description
Following through Django tutorial, after migrate and createsuperuser etc, tried to modify the saved first name and last name for the super user on the admin page, got an OperationalError suggesting that no such table: main.auth_userold.

Details
This exception is encountered for both Django 2.1.3 and 2.1.4 with Python 3.7.1 under macOS High Sierra, and have effects even when the user is trying to modify other models (like the polls.models.Question' model').

However, when using Django 2.1.4 under PyPy3.5 version 6.0.0 or using Django 1.11.14 under Python2 and PyPy, no exceptions were encountered when performing the same actions.

SQLite .table command showed that under all the aforementioned installations, the database consists of the same table sets auth_group auth_user_user_permissions auth_group_permissions django_admin_log auth_permission django_content_type auth_user django_migrations auth_user_groups django_session.

Stack Trace

Internal Server Error: /admin/auth/user/1/change/
Traceback (most recent call last):
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 296, in execute
    return Database.Cursor.execute(self, query, params)
sqlite3.OperationalError: no such table: main.auth_user__old

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

Traceback (most recent call last):
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
    response = get_response(request)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/core/handlers/base.py", line 126, in _get_response
    response = self.process_exception_by_middleware(e, request)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/core/handlers/base.py", line 124, in _get_response
    response = wrapped_callback(request, *callback_args, **callback_kwargs)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/contrib/admin/options.py", line 604, in wrapper
    return self.admin_site.admin_view(view)(*args, **kwargs)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/utils/decorators.py", line 142, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/views/decorators/cache.py", line 44, in _wrapped_view_func
    response = view_func(request, *args, **kwargs)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/contrib/admin/sites.py", line 223, in inner
    return view(request, *args, **kwargs)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1640, in change_view
    return self.changeform_view(request, object_id, form_url, extra_context)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/utils/decorators.py", line 45, in _wrapper
    return bound_method(*args, **kwargs)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/utils/decorators.py", line 142, in _wrapped_view
    response = view_func(request, *args, **kwargs)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1525, in changeform_view
    return self._changeform_view(request, object_id, form_url, extra_context)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/contrib/admin/options.py", line 1571, in _changeform_view
    self.log_change(request, new_object, change_message)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/contrib/admin/options.py", line 826, in log_change
    change_message=message,
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/contrib/admin/models.py", line 35, in log_action
    change_message=change_message,
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/db/models/query.py", line 413, in create
    obj.save(force_insert=True, using=self.db)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/db/models/base.py", line 718, in save
    force_update=force_update, update_fields=update_fields)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/db/models/base.py", line 748, in save_base
    updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/db/models/base.py", line 831, in _save_table
    result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/db/models/base.py", line 869, in _do_insert
    using=using, raw=raw)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/db/models/manager.py", line 82, in manager_method
    return getattr(self.get_queryset(), name)(*args, **kwargs)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/db/models/query.py", line 1136, in _insert
    return query.get_compiler(using=using).execute_sql(return_id)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/db/models/sql/compiler.py", line 1289, in execute_sql
    cursor.execute(sql, params)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/db/backends/utils.py", line 100, in execute
    return super().execute(sql, params)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/db/backends/utils.py", line 68, in execute
    return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/db/backends/utils.py", line 77, in _execute_with_wrappers
    return executor(sql, params, many, context)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/db/utils.py", line 89, in __exit__
    raise dj_exc_value.with_traceback(traceback) from exc_value
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/db/backends/utils.py", line 85, in _execute
    return self.cursor.execute(sql, params)
  File "/Users/hzhao/Workstation/env/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py", line 296, in execute
    return Database.Cursor.execute(self, query, params)
django.db.utils.OperationalError: no such table: main.auth_user__old
[04/Dec/2018 19:39:24] "POST /admin/auth/user/1/change/ HTTP/1.1" 500 208079

Change History (4)

comment:1 by Simon Charette, 6 years ago

Pretty sure this is related to #29182.

comment:2 by Simon Charette, 6 years ago

Hello Hansheng Zhao,

Could you provide the output of the following commands in a Python shell of environment affected by this issue.

print(sqlite3.version)
print(sqlite3.sqlite_version)
print(sqlite3.connect('file::memory:').cursor().execute('PRAGMA compile_options').fetchall())

comment:3 by Paweł Gucwa, 6 years ago

I have the same error:

>>> import sqlite3
>>> print(sqlite3.version)
2.6.0
>>> print(sqlite3.sqlite_version)
3.26.0
>>> print(sqlite3.connect('file::memory:').cursor().execute('PRAGMA compile_options').fetchall())
[('COMPILER=gcc-8.2.0',), ('ENABLE_COLUMN_METADATA',), ('ENABLE_DBSTAT_VTAB',), ('ENABLE_FTS3',), ('ENABLE_FTS3_PARENTHESIS',), ('ENABLE_FTS3_TOKENIZER',), ('ENABLE_FTS4',), ('ENABLE_FTS5',), ('ENABLE_JSON1',), ('ENABLE_LOAD_EXTENSION',), ('ENABLE_PREUPDATE_HOOK',), ('ENABLE_RTREE',), ('ENABLE_SESSION',), ('ENABLE_STMTVTAB',), ('ENABLE_UNLOCK_NOTIFY',), ('ENABLE_UPDATE_DELETE_LIMIT',), ('HAVE_ISNAN',), ('LIKE_DOESNT_MATCH_BLOBS',), ('MAX_SCHEMA_RETRY=25',), ('MAX_VARIABLE_NUMBER=250000',), ('OMIT_LOOKASIDE',), ('SECURE_DELETE',), ('SOUNDEX',), ('TEMP_STORE=1',), ('THREADSAFE=1',)]
>>> 

Version 0, edited 6 years ago by Paweł Gucwa (next)

comment:4 by Simon Charette, 6 years ago

Resolution: duplicate
Status: newclosed

Thanks for confirming Paweł, that seems to be an issue with SQLite 3.26. Let's discuss it in #29182.

Note: See TracTickets for help on using tickets.
Back to Top