django error _admin history

django 报错:django.db.utils.OperationalError: no such table: main.auth_user__old

In Django the Tutorial , the admin page after modify, view history
being given.
Django Version: 2.1 Python Version: 3.7 The two versions of the problem is no problem in sqlite3.
Reference: StackOverflow
discussion of this issue,
the successful solution program:
in Lib \ site-packages \ django \ db \ backends \ sqlite3 \ schema.py , the following modifications:

   def __enter__(self):
        # Some SQLite schema alterations need foreign key constraints to be
        # disabled. Enforce it here for the duration of the transaction.

        self.connection.disable_constraint_checking()
        self.connection.cursor().execute('PRAGMA foreign_keys = 0')  ## 自己加的
        self.connection.cursor().execute('PRAGMA legacy_alter_table = ON') # 自己加的
        return super().__enter__()

Note that this modified shcema.py did not take effect, I db.sqlite3 delete files, re-python manage.py makemigrations, python manage.py migrate.
Rebuild the database file, OK.

Guess you like

Origin www.cnblogs.com/ShawSpring/p/10943147.html