I'm currently working on my first Django project, and I'm following the tutorial guide made by Mosh in his video in Python for Beginners. The project is an online shop and I keep getting stuck when I'm adding new products to my products list(video time stamp - 5:41:07). I followed all his steps but kept getting stuck on the same part no matter how I looked for the answer.
OperationalError at /admin/products/product/add/
no such table: main.auth_user__old
Request Method: POST
Request URL: http://127.0.0.1:8000/admin/products/product/add/
Django Version: 4.0.4
Exception Type: OperationalError
Exception Value:
no such table: main.auth_user__old
Exception Location: D:\programming\phython projects\project_5(PyShop)\lib\site-packages\django\db\backends\sqlite3\base.py, line 477, in execute
Python Executable: D:\programming\phython projects\project_5(PyShop)\Scripts\python.exe
Python Version: 3.10.2
Python Path:
['D:\\programming\\phython projects\\project_5(PyShop)',
'C:\\Users\\LENOVO\\AppData\\Local\\Programs\\Python\\Python310\\python310.zip',
'C:\\Users\\LENOVO\\AppData\\Local\\Programs\\Python\\Python310\\DLLs',
'C:\\Users\\LENOVO\\AppData\\Local\\Programs\\Python\\Python310\\lib',
'C:\\Users\\LENOVO\\AppData\\Local\\Programs\\Python\\Python310',
'D:\\programming\\phython projects\\project_5(PyShop)',
'D:\\programming\\phython projects\\project_5(PyShop)\\lib\\site-packages']
Server time: Thu, 19 May 2022 07:49:11 +0000
this is my line of code
views module in products package:
from django.http import HttpResponse
from django.shortcuts import render
def index(request):
return HttpResponse('Hello World')
def new(request):
return HttpResponse('New Products')
url module in products package:
from django.urls import path
from . import views
urlpatterns = [
path('', views.index),
path('new', views.new)
]
modules module in pyshop package:
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=2083)
class Offer(models.Model):
code = models.CharField(max_length=10)
description = models.CharField(max_length=225)
discount = models.FloatField()
modules module in pyshop package:
from django.apps import AppConfig
class ProductsConfig(AppConfig):
name = 'products'
urls module in pyshop package:
from django.contrib import admin
from django.urls import path, include
urlpatterns = [
path('admin/', admin.site.urls),
path('products/', include('products.urls'))
]
admin.py module in pyshop package:
from django.contrib import admin
from .models import Product
admin.site.register(Product)
I also made sure to input these two lines before opening the live server:
python manage.py makemigrations app
python manage.py migrate app