Python Django - 没有这样的表:main.auth_user__old

声明:本页面是StackOverFlow热门问题的中英对照翻译,遵循CC BY-SA 4.0协议,如果您需要使用它,必须同样遵循CC BY-SA许可,注明原文地址和作者信息,同时你必须将它归于原作者(不是我):StackOverFlow 原文地址: http://stackoverflow.com/questions/53637182/
Warning: these are provided under cc-by-sa 4.0 license. You are free to use/share it, But you must attribute it to the original authors (not me): StackOverFlow

提示:将鼠标放在中文语句上可以显示对应的英文。显示中英文
时间:2020-08-19 20:19:58  来源:igfitidea点击:

Django - No such table: main.auth_user__old

pythondjangopython-3.xdjango-models

提问by northernSage

I was following the first app tutorialfrom the official Django docs and got this error when trying to save some changes made through the admin page. I did some research on it, but the possible solutions I was able to find, such as migrating the db, simply won't work. Just let me know if you want to see some specific part of my code.

我正在关注官方 Django 文档中的第一个应用程序教程,并在尝试保存通过管理页面所做的一些更改时遇到此错误。我对它进行了一些研究,但我能够找到的可能解决方案(例如迁移数据库)根本行不通。如果您想查看我的代码的某些特定部分,请告诉我。

Following is error:

以下是错误:

OperationalError at /admin/polls/question/1/change/ no such table: main.auth_user__old Request Method: POST Request URL: http://127.0.0.1:8000/admin/polls/question/1/change/Django Version: 2.1.4 Exception Type: OperationalError Exception Value: no such table: main.auth_user__old Exception Location: /Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py in execute, line 296 Python Executable: /Users/gfioravante/Projects/test_app/ta_env/bin/python3 Python Version: 3.7.1 Python Path:
['/Users/gfioravante/Projects/test_app/test_app', '/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7/lib-dynload', '/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages'] Server time: Wed, 5 Dec 2018 16:45:00 +0000

OperationalError at /admin/polls/question/1/change/ 没有这样的表:main.auth_user__old 请求方法:POST 请求 URL:http: //127.0.0.1:8000/admin/polls/question/1/change/ Django 版本: 2.1.4 异常类型:OperationalError 异常值:没有这样的表:main.auth_user__old 异常位置:/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/backends/sqlite3/base .py 在执行中,第 296 行 Python 可执行文件:/Users/gfiorvante/Projects/test_app/ta_env/bin/python3 Python 版本:3.7.1 Python 路径:
['/Users/gfioravante/Projects/test_app/test_app', '/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python37.zip', '/usr/local /Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/lib/python3.7', '/usr/local/Cellar/python/3.7.1/Frameworks/Python.framework/Versions/3.7/ lib/python3.7/lib-dynload', '/Users/gfiorvante/Projects/test_app/ta_env/lib/python3.7/site-packages'] 服务器时间:2018 年 12 月 5 日星期三 16:45:00 +0000

and the traceback:

和回溯:

Environment:

Request Method: POST Request URL: http://127.0.0.1:8000/admin/polls/question/1/change/

Django Version: 2.1.4 Python Version: 3.7.1 Installed Applications: ['polls.apps.PollsConfig', 'django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles'] Installed Middleware: ['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django.middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickHymaning.XFrameOptionsMiddleware']

Traceback:

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/backends/utils.py" in _execute 85. return self.cursor.execute(sql, params)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py" in execute 296. return Database.Cursor.execute(self, query, params)

The above exception (no such table: main.auth_user__old) was the direct cause of the following exception:

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/core/handlers/exception.py" in inner 34. response = get_response(request)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response 126. response = self.process_exception_by_middleware(e, request)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/core/handlers/base.py" in _get_response 124. response = wrapped_callback(request, *callback_args, **callback_kwargs)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/contrib/admin/options.py" in wrapper 604. return self.admin_site.admin_view(view)(*args, **kwargs)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/utils/decorators.py" in _wrapped_view 142. response = view_func(request, *args, **kwargs)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/views/decorators/cache.py" in _wrapped_view_func 44. response = view_func(request, *args, **kwargs)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/contrib/admin/sites.py" in inner 223. return view(request, *args, **kwargs)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/contrib/admin/options.py" in change_view 1640. return self.changeform_view(request, object_id, form_url, extra_context)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/utils/decorators.py" in _wrapper 45. return bound_method(*args, **kwargs)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/utils/decorators.py" in _wrapped_view 142. response = view_func(request, *args, **kwargs)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/contrib/admin/options.py" in changeform_view 1525. return self._changeform_view(request, object_id, form_url, extra_context)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/contrib/admin/options.py" in _changeform_view 1571. self.log_change(request, new_object, change_message)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/contrib/admin/options.py" in log_change 826. change_message=message,

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/contrib/admin/models.py" in log_action 35. change_message=change_message,

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/models/manager.py" in manager_method 82. return getattr(self.get_queryset(), name)(*args, **kwargs)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/models/query.py" in create 413. obj.save(force_insert=True, using=self.db)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/models/base.py" in save 718. force_update=force_update, update_fields=update_fields)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/models/base.py" in save_base 748. updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/models/base.py" in _save_table 831. result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/models/base.py" in _do_insert 869. using=using, raw=raw)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/models/manager.py" in manager_method 82. return getattr(self.get_queryset(), name)(*args, **kwargs)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/models/query.py" in _insert 1136. return query.get_compiler(using=using).execute_sql(return_id)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/models/sql/compiler.py" in execute_sql 1289. cursor.execute(sql, params)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/backends/utils.py" in execute 100. return super().execute(sql, params)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/backends/utils.py" in execute 68. return self._execute_with_wrappers(sql, params, many=False, executor=self._execute)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/backends/utils.py" in _execute_with_wrappers 77. return executor(sql, params, many, context)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/backends/utils.py" in _execute 85. return self.cursor.execute(sql, params)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/utils.py" in exit89. raise dj_exc_value.with_traceback(traceback) from exc_value

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/backends/utils.py" in _execute 85. return self.cursor.execute(sql, params)

File "/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py" in execute 296. return Database.Cursor.execute(self, query, params)

Exception Type: OperationalError at /admin/polls/question/1/change/ Exception Value: no such table: main.auth_user__old

环境:

请求方式:POST 请求地址:http: //127.0.0.1: 8000/admin/polls/question/1/change/

Django 版本:2.1.4 Python 版本:3.7.1 已安装的应用程序:['polls.apps.PollsConfig'、'django.contrib.admin'、'django.contrib.auth'、'django.contrib.contenttypes'、'django .contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles'] 安装的中间件:['django.middleware.security.SecurityMiddleware', 'django.contrib.sessions.middleware.SessionMiddleware', 'django .middleware.common.CommonMiddleware', 'django.middleware.csrf.CsrfViewMiddleware', 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middlesiddleFrameOptions ']

追溯:

_execute 85 中的文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/backends/utils.py”。return self.cursor.execute(sql, params)

文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py”在执行 296.return Database.Cursor.execute(self, query,参数)

上述异常(没有这样的表:main.auth_user__old)是以下异常的直接原因:

文件“/Users/gfiorvante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/core/handlers/exception.py”在内部 34. response = get_response(request)

_get_response 126 中的文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/core/handlers/base.py”. response = self.process_exception_by_middleware(e, request)

文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/core/handlers/base.py”在_get_response 124. response =wrapped_callback(request, *callback_args, **callback_kwargs)

包装器 604 中的文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/contrib/admin/options.py”。返回 self.admin_site.admin_view(view)(*args, **夸格)

文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/utils/decorators.py” in _wrapped_view 142. response = view_func(request, *args, **kwargs)

_wrapped_view_func 中的文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/views/decorators/cache.py” 44. response = view_func(request, *args, **kwargs)

文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/contrib/admin/sites.py”在内部 223.return view(request, *args, **kwargs)

文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/contrib/admin/options.py”在change_view 1640.return self.changeform_view(request, object_id, form_url, extra_context)

_wrapper 45 中的文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/utils/decorators.py”。return bound_method(*args, **kwargs)

文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/utils/decorators.py” in _wrapped_view 142. response = view_func(request, *args, **kwargs)

changeform_view 1525 中的文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/contrib/admin/options.py”。返回 self._changeform_view(request, object_id, form_url, extra_context)

文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/contrib/admin/options.py” in _changeform_view 1571.self.log_change(request, new_object, change_message)

log_change 826 中的文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/contrib/admin/options.py”。change_message=message,

log_action 35.change_message=change_message 中的文件“/Users/gfiorvante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/contrib/admin/models.py”

文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/models/manager.py” in manager_method 82. return getattr(self.get_queryset(), name)(* args, **kwargs)

文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/models/query.py”在创建 413.obj.save(force_insert=True, using=self.db )

文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/models/base.py”保存在718.force_update=force_update, update_fields=update_fields)

save_base 748 中的文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/models/base.py”。updated = self._save_table(raw, cls, force_insert, force_update , 使用, update_fields)

_save_table 831.result = self._do_insert(cls._base_manager, using, fields , update_pk, 原始)

_do_insert 869 中的文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/models/base.py”。using=using, raw=raw)

文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/models/manager.py” in manager_method 82. return getattr(self.get_queryset(), name)(* args, **kwargs)

_insert 1136 中的文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/models/query.py”。return query.get_compiler(using=using).execute_sql(return_id )

文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/models/sql/compiler.py”在execute_sql 1289. cursor.execute(sql, params)

文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/backends/utils.py”在执行100.return super().execute(sql, params)

文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/backends/utils.py”在执行 68. 返回 self._execute_with_wrappers(sql, params, many=False, executor=self._execute)

_execute_with_wrappers 中的文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/backends/utils.py” 77. return executor(sql, params, many, context)

_execute 85 中的文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/backends/utils.py”。return self.cursor.execute(sql, params)

退出89 中的文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/utils.py” 。从 exc_value 提高 dj_exc_value.with_traceback(traceback)

_execute 85 中的文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/backends/utils.py”。return self.cursor.execute(sql, params)

文件“/Users/gfioravante/Projects/test_app/ta_env/lib/python3.7/site-packages/django/db/backends/sqlite3/base.py”在执行 296.return Database.Cursor.execute(self, query,参数)

异常类型:OperationalError at /admin/polls/question/1/change/ 异常值:没有这样的表:main.auth_user__old

采纳答案by BenM

I just came across this myself, it looks to be related to https://code.djangoproject.com/ticket/29182. For now, you can just downgrade your version of sqlite to a version prior to 2.6 (e.g. 2.5.1)

我自己刚遇到这个,它看起来与https://code.djangoproject.com/ticket/29182有关。现在,您可以将您的 sqlite 版本降级到 2.6 之前的版本(例如 2.5.1)

回答by nurealam siddiq

Get rid of this issue easily maintaining the following steps:

轻松摆脱这个问题,维护以下步骤:

  1. keep django version 2.1.5 (the issue addressed in this version) pip install django==2.1.5
  2. Delete the SQLite db
  3. Migrate again python manage.py makemigrationsand then python manage.py migrate
  4. Start the server python manage.py runserver
  1. 保留 django 版本 2.1.5(此版本中解决的问题) pip install django==2.1.5
  2. 删除 SQLite 数据库
  3. 再次迁移python manage.py makemigrations,然后python manage.py migrate
  4. 启动服务器 python manage.py runserver

DONE!

完毕!

回答by Imre Kis

The problem is caused by the modified behaviour of the ALTER TABLE RENAMEstatement in SQLite 3.26.0 (see compatiblity note). They also introduced the PRAGMA legacy_alter_table = ONstatement in order to maintain the compatibility with previous versions. The upcoming Django release 2.1.5utilizes the previously mentioned statement as a hotfix. It's expected on January 1, 2019.

该问题是由ALTER TABLE RENAMESQLite 3.26.0 中语句的修改行为引起的(请参阅兼容性说明)。他们还引入了该PRAGMA legacy_alter_table = ON声明,以保持与以前版本的兼容性。即将发布的Django 版本 2.1.5使用前面提到的语句作为修补程序。预计在 2019 年 1 月 1 日。

回答by zurbaranf

Just only did this and I resolved the problem:

只是这样做,我解决了这个问题:

pip install Django --upgrade

Then:

然后:

python manage.py migrate

python manage.py makemigrations app

python manage.py migrate

回答by Namal Jayasundara

go to this folder django/db/backends/sqlite3

转到此文件夹 django/db/backends/sqlite3

backup schema.pyfile to another folder

备份schema.py文件到另一个文件夹

open the original schema.py in a text editor

在文本编辑器中打开原始 schema.py

there you can see a code snippet like

在那里你可以看到一个代码片段,比如

    def __enter__(self):
    # Some SQLite schema alterations need foreign key constraints to be
     # disabled. Enforce it here for the duration of the schema edition.
     if not self.connection.disable_constraint_checking():
         raise NotSupportedError(
             'SQLite schema editor cannot be used while foreign key '
             'constraint checks are enabled. Make sure to disable them '
             'before entering a transaction.atomic() context because '
             'SQLite3 does not support disabling them in the middle of '
             'a multi-statement transaction.'
         )
     self.connection.cursor().execute('PRAGMA legacy_alter_table = ON')
     return super().__enter__()

comment them and paste the following code snippet

评论它们并粘贴以下代码片段

     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 legacy_alter_table = ON')
    return super().__enter__()

This worked for me. (the backup for the schema.py is in case the work go wrong ; D )

这对我有用。(schema.py 的备份以防工作出错;D)

for more info

欲了解更多信息

https://github.com/django/django/pull/10733/commits/c8ffdbe514b55ff5c9a2b8cb8bbdf2d3978c188f#diff-0c8f495bfee773ab7b5409533bd6d7ef

https://github.com/django/django/pull/10733/commits/c8ffdbe514b55ff5c9a2b8cb8bbdf2d3978c188f#diff-0c8f495bfee773ab7b5409533bd6d7ef

回答by MING WU

Here is what I did to solve this problem:

这是我为解决此问题所做的工作:

  1. Go to the virtual environment and install [email protected]

    pip install django==2.1.7
    
  2. Delete the db.sqlite3file in your root folder.

  3. Create the new db.sqlite3in your root folder.
  4. Re-run migrations:

    python3 manage.py makemigrations
    
    python3 manage.py migrate
    
  1. 进入虚拟环境并安装 [email protected]

    pip install django==2.1.7
    
  2. 删除db.sqlite3根文件夹中的文件。

  3. db.sqlite3在根文件夹中创建新的。
  4. 重新运行迁移:

    python3 manage.py makemigrations
    
    python3 manage.py migrate
    

Now it should be working all right.

现在它应该可以正常工作了。

回答by Tms91

I solved the problem by upgrading Django from 2.1.4 to 2.1.5, but I had to rebuild the project anew, because the bug seems to be somehow related to the objects I inserted into the database by using the old version of Django.

我通过将 Django 从 2.1.4 升级到 2.1.5 解决了这个问题,但是我不得不重新重建项目,因为这个 bug 似乎与我使用旧版本的 Django 插入到数据库中的对象有某种关系。

回答by Milan Adhikari

  1. First, stop the server and delete db.sqlite3.
  2. Then, you need to run: python manage.py makemigrations python manage.py migrate
  3. After running this command you need to create super user. To Create Super User, run: python manage.py createsuperuser Enter the super user details there.
  4. Run your server again.
  1. 首先,停止服务器并删除db.sqlite3。
  2. 然后,您需要运行: python manage.py makemigrations python manage.py migrate
  3. 运行此命令后,您需要创建超级用户。要创建超级用户,请运行: python manage.py createsuperuser 在那里输入超级用户详细信息。
  4. 再次运行您的服务器。

There you go.

你去吧。

回答by Ithomson90

Same thing is happened to me, very frustrating. I use anaconda for my environments, I found that I couldn't remove sqlite without immediately reinstalling the most up to date version of sqlite. Trying an older version of django also didn't seem to work. The only solution that has worked for me is by using a PostgreSQL database. It's certainly not ideal but I am planning on utilising the PostgreSQL database in the future so this wasn't a complete waste of time. If you find yourself in the same place as I was then this videomay be helpful if you want to know how to connect the PostgreSQL database with your django project.

同样的事情发生在我身上,非常令人沮丧。我在我的环境中使用 anaconda,我发现如果不立即重新安装最新版本的 sqlite,我就无法删除 sqlite。尝试旧版本的 django 似乎也不起作用。对我有用的唯一解决方案是使用 PostgreSQL 数据库。这当然不理想,但我计划在未来使用 PostgreSQL 数据库,所以这不是完全浪费时间。如果你发现自己和我在同一个地方,那么如果你想知道如何将 PostgreSQL 数据库与你的 django 项目连接,这个视频可能会有所帮助。

You'll need to install the postgreSQL database before actually making the changes in settings.py, the installation is more of less clicking Next on all the options. However, remember the username and password you use during installation.

在实际更改 settings.py 之前,您需要安装 postgreSQL 数据库,安装更多的是在所有选项上单击下一步。但是,请记住您在安装过程中使用的用户名和密码。

回答by Aravind Krishna Saravu

For the above problem and solution is:

针对上述问题,解决方法是:

1) Go to the terminal and type in pip install django==2.1.7or the latest version of django

1)到终端输入pip install django==2.1.7或最新版本的django

2) After the installation,In the terminal type in python manage.py makemigrations,and then python manage.py migrate

2)安装完成后,在终端输入python manage.py makemigrations,然后python manage.py migrate

3) In the terminal,Start the server with code python manage.py runserver

3)在终端中,用代码启动服务器 python manage.py runserver

4) Login to the admin server with the password and the add the product,It will successfully add the product.

4) 使用密码登录管理服务器并添加产品,即可成功添加产品。