我正在创建我的第一个Django项目。将数据添加到产品内的文本字段后,按保存按钮时出现错误。这是我得到的错误:
OperationalError at /admin/products/product/add/
no such table: main.auth_user__old
Request Method: POST
Request URL: http://127.0.0.1:8080/admin/products/product/add/
Django Version: 2.1
Exception Type: OperationalError
Exception Value:
no such table: main.auth_user__old
Exception Location: C:\Users\Ehtsham\PycharmProjects\firstproject\venv\lib\site-packages\django\db\backends\sqlite3\base.py in execute, line 296
Python Executable: C:\Users\Ehtsham\PycharmProjects\firstproject\venv\Scripts\python.exe
Python Version: 3.8.1
Python Path:
['C:\\Users\\Ehtsham\\PycharmProjects\\firstproject',
'C:\\Users\\Ehtsham\\AppData\\Local\\Programs\\Python\\Python38-32\\python38.zip',
'C:\\Users\\Ehtsham\\AppData\\Local\\Programs\\Python\\Python38-32\\DLLs',
'C:\\Users\\Ehtsham\\AppData\\Local\\Programs\\Python\\Python38-32\\lib',
'C:\\Users\\Ehtsham\\AppData\\Local\\Programs\\Python\\Python38-32',
'C:\\Users\\Ehtsham\\PycharmProjects\\firstproject\\venv',
'C:\\Users\\Ehtsham\\PycharmProjects\\firstproject\\venv\\lib\\site-packages',
'C:\\Users\\Ehtsham\\PycharmProjects\\firstproject\\venv\\lib\\site-packages\\setuptools-40.8.0-py3.8.egg',
'C:\\Users\\Ehtsham\\PycharmProjects\\firstproject\\venv\\lib\\site-packages\\pip-19.0.3-py3.8.egg']
Server time: Sun, 5 Jan 2020 15:00:27 +0000
我之前也做过迁移:
(venv) C:\Users\Ehtsham\PycharmProjects\firstproject>python manag
e.py makemigrations
Migrations for 'products':
products\migrations\0002_offers.py
- Create model Offers
(venv) C:\Users\Ehtsham\PycharmProjects\firstproject>python manag
e.py migrate
Operations to perform:
Apply all migrations: admin, auth, contenttypes, products, sess
ions
Running migrations:
Applying products.0002_offers... OK
我在PyCharm IDE上使用Django 2.1版和SQLite DB浏览器。
答案 0 :(得分:0)
它显示您的django版本是“ Django版本:2.1”
您需要升级django。如果它是一个新项目。 请执行以下步骤。
步骤:1 >> pip install Django --upgrade
步骤:2 >> python manage.py makemigrations
步骤:3 >> python manage.py migrate
Ste:-4 >> python manage.py runserver