Django Operational error no such table: main.auth_user__old

stumbled with this error after following tutorial step by step , when I try adding a new Genre to movies app and save changes a message appears telling me that there is no such table
this was the problem with the YouTube free Tutorial version also
i looked this problem on stackoverflow but those solutions don’t work

1 Like

Please share the relevant code snippet in a code block. Also include a full stack trace if you have one (error probably says it was thrown at some particular line of your code).

OperationalError at /admin/movies/genre/add/

no such table: main.auth_user__old

Request Method: POST
Request URL: http://127.0.0.1:8000/admin/movies/genre/add/
Django Version: 2.1
Exception Type: OperationalError
Exception Value: no such table: main.auth_user__old
Exception Location: C:\Users\olado.virtualenvs\vidly-BM-idFl-\lib\site-packages\django\db\backends\sqlite3\base.py in execute, line 296
Python Executable: C:\Users\olado.virtualenvs\vidly-BM-idFl-\Scripts\python.exe
Python Version: 3.10.5
Python Path: [‘C:\brandnewprojectcalledselenium\vidly’, ‘C:\Users\olado\AppData\Local\Programs\Python\Python310\python310.zip’, ‘C:\Users\olado\AppData\Local\Programs\Python\Python310\DLLs’, ‘C:\Users\olado\AppData\Local\Programs\Python\Python310\lib’, ‘C:\Users\olado\AppData\Local\Programs\Python\Python310’, ‘C:\Users\olado\.virtualenvs\vidly-BM-idFl-’, ‘C:\Users\olado\.virtualenvs\vidly-BM-idFl-\lib\site-packages’]
Server time: Tue, 23 Aug 2022 11:15:11 +0000

Is that table name supposed to have an extra underscore (_) character? That looks like a typo: auth_user__old (maybe that should be auth_user_old?)

i didn’t create any table with either names , i just followed the tutorial step by step
the step at which i got this error corresponds to the 12th section in complete python mastery for beginners and to be exact it is the 9th lecture (customizing the Admin ) at 3:03 when he clicks SAVE , in my case this error appears

What code are you running?

Which course lesson is this tied to? Ideally a link to the lesson would be appreciated.

has this been reported to mosh personally ?

Mosh does not generally monitor the forums himself (though he does have a user: programmingwithmosh). His support team is fairly responsive if you @ mention them (codewithmosh). Most of us who are responding on this forum (like me) are other students.

@codewithmosh
Team please trace the fault in my case and tell me if it is a matter of software version or not
I repeat : I followed the tutorial step by step especially (pipenv install django==2.1)

What does your admin.py file look like? Perhaps you can copy/paste the contents of your admin.py and models.py files into codeblocks:

def some_function():
  """Like this."""

below , I will paste the codes of admin and models files in two separate comments in the following order :
content of admin.py file
content of models.py file

from lib2to3.pgen2.token import GREATER
from django.contrib import admin
from .models import Genre, Movie

class GenreAdmin(admin.ModelAdmin):
list_display = (‘id’, ‘name’)

admin.site.register(Genre, GenreAdmin)
admin.site.register(Movie)

from platform import release
from turtle import title
from django.db import models
from django.utils import timezone

class Genre(models.Model):
name = models.CharField(max_length=255)

def __str__(self):
    return self.name

class Movie(models.Model):
title = models.CharField(max_length=255)
release_year = models.IntegerField()
number_in_stock = models.IntegerField()
daily_rate = models.FloatField()
genre = models.ForeignKey(Genre, on_delete=models.CASCADE)
date_created = models.DateTimeField(default=timezone.now)

I have same problem and I tried to fix it but I can’t, could anyone help us?

Your new error looks like a problem with needing to run using an elevated terminal (as in, running your terminal as an admin). I am not certain, just giving my best guess.

Which error @RaghadCoder ? The original error mentioned in the first post of this thread?

yes, it is the original error in the first post of this thread