0

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/

*Here are errors detail: * Environment:

Request Method: POST Request URL: 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

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)

tithidey
  • 17
  • 2
  • 9

1 Answers1

1

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.

  1. Go to the virtual environment and install django(version 2.1.7) pip install django==2.1.7
  2. Delete the db.sqlite3 file in your root folder. (Search for it in your PyCharm projects in the root folder if that's where it's stored)
  3. Create a new db.sqlite3 by doing python manage.py makemigrations
  4. Re-run migrations, after doing python manage.py makemigrations run python manage.py migrate .
tea
  • 26
  • 1
  • 1
  • 5