简体   繁体   English

我正在尝试在我的新项目中添加新产品。 但为什么显示(没有这样的表:main.auth_user__old)

[英]I'm trying to add new product on my new project. But why it's show (no such table: main.auth_user__old)

I'm trying to add new product details on product table.我正在尝试在产品表上添加新的产品详细信息。 But whenever I try to save this it's show me但是每当我尝试保存它时,它都会向我展示

OperationalError at /admin/products/product/add/ /admin/products/product/add/ 处的操作错误

*Here are errors detail: * Environment: *这里是错误的详细信息:*环境:

Request Method: POST Request URL: http://127.0.0.1:8000/admin/products/product/add/请求方式:POST 请求地址: http : //127.0.0.1 : 8000/admin/products/product/add/

Exception Type: OperationalError at /admin/products/product/add/ Exception Value: no such table: main.auth_user__old异常类型:OperationalError at /admin/products/product/add/ 异常值:没有这样的表:main.auth_user__old

This is model这是模型

from django.db import models


class Product(models.Model):
    name = models.CharField(max_length=255)
    price = models.FloatField()
    stock = models.IntegerField()
    image_url = models.CharField(max_length=2088)


class Offer(models.Model):
    code = models.CharField(max_length=10)
    description = models.CharField(max_length=255)
    discount = models.FloatField()

admin行政

from django.contrib import admin
from .models import Product

admin.site.register(Product)

I don't know if you are still struggling with this, but I had the same issue.我不知道你是否还在为此苦苦挣扎,但我遇到了同样的问题。 The solution was deleting and re-downloading db.sqlite3 with an older version of django.解决方案是使用旧版本的 django 删除并重新下载db.sqlite3

  1. Go to the virtual environment and install django(version 2.1.7) pip install django==2.1.7进入虚拟环境安装django(2.1.7版) pip install django==2.1.7
  2. Delete the db.sqlite3 file in your root folder.删除根文件夹中的db.sqlite3文件。 (Search for it in your PyCharm projects in the root folder if that's where it's stored) (如果它存储在根文件夹中,请在您的 PyCharm 项目中搜索它)
  3. Create a new db.sqlite3 by doing python manage.py makemigrations创建一个新的db.sqlite3python manage.py makemigrations
  4. Re-run migrations, after doing python manage.py makemigrations run python manage.py migrate .重新运行迁移,在执行python manage.py makemigrations运行python manage.py migrate

暂无
暂无

声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.

相关问题 当我尝试在 Django 管理站点中将新产品添加到我的 PRODUCTS 组时,它给了我一个没有这样的表:main.auth_user__old 错误 - When I try to add a new product to my PRODUCTS group in the Django Admin site it gives me a no such table: main.auth_user__old error 坚持 Django 项目教程,我在 Udemy 上做 - OperationalError at /admin/jobs/job/add/ 没有这样的表:main.auth_user__old - Stuck on Django project tutorial I'm doing on Udemy - OperationalError at /admin/jobs/job/add/ no such table: main.auth_user__old Django - 没有这样的表:main.auth_user__old - Django - No such table: main.auth_user__old 没有这样的表:main.auth_user__old (OperationalError) - no such table: main.auth_user__old (OperationalError) 没有这样的表:main.auth_user__old - no such table: main.auth_user__old "如何修复 - 没有这样的表:main.auth_user__old" - How to fix-no such table: main.auth_user__old OperationalError at /admin/myschoolweb/album/add/ - 没有这样的表:main.auth_user__old - OperationalError at /admin/myschoolweb/album/add/ - no such table: main.auth_user__old Django 错误没有这样的表:main.auth_user__old - Django error no such table: main.auth_user__old 没有这样的表:main.auth_user__old 在节区中保存表时 - no such table: main.auth_user__old while saving tables in the section area 无法让django-admin启动新项目。 寻找我删除的旧项目 - Can't get a django-admin to start a new project. It's looking for an old project I deleted
 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM