0

I get this error when I add a something to the text field.I'm trying to create a project where someone can enter random messages.

OperationalError at /admin/submit/submit/add/
no such table: main.auth_user__old
Request Method: POST
Request URL:    http://127.0.0.1:8000/admin/submit/submit/add/
Django Version: 2.1
Exception Type: OperationalError
Exception Value:    
no such table: main.auth_user__old
Exception Location: D:\Anaconda1\lib\site-packages\django\db\backends\sqlite3\base.py in execute, line 296
Python Executable:  D:\Anaconda1\python.exe
Python Version: 3.8.3
Python Path:    
['D:\\PyProjects\\Website',
 'D:\\Anaconda1\\python38.zip',
 'D:\\Anaconda1\\DLLs',
 'D:\\Anaconda1\\lib',
 'D:\\Anaconda1',
 'C:\\Users\\heman\\AppData\\Roaming\\Python\\Python38\\site-packages',
 'D:\\Anaconda1\\lib\\site-packages',
 'D:\\Anaconda1\\lib\\site-packages\\win32',
 'D:\\Anaconda1\\lib\\site-packages\\win32\\lib',
 'D:\\Anaconda1\\lib\\site-packages\\Pythonwin']
Server time:    Mon, 5 Oct 2020 17:19:26 +000

This is my models.py

from django.db import models

# Create your models here.
class Submit(models.Model):
    title = models.TextField(max_length=140, default='SOME STRING')
    status = models.TextField(max_length=140, default='SOME STRING')
    description = models.TextField(max_length=140, default='SOME STRING')

Here is my setting.py installed apps

INSTALLED_APPS = [
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'submit.apps.SubmitConfig',
]

Here is my apps.py

from django.apps import AppConfig


class SubmitConfig(AppConfig):
    name = 'submit'

Here is my admin.py

from django.contrib import admin
from .models import Submit

# Register your models here.

admin.site.register(Submit)

I also ran python manage.py makemigrations and python manage.py migrate Please help me...Thanks in advance

  • Try `python manage.py makemigrations` and `python manage.py migrate` and show input, please – Fedor Soldatkin Oct 05 '20 at 17:40
  • ```D:\PyProjects\Website>python manage.py makemigrations No changes detected D:\PyProjects\Website>python manage.py migrate Operations to perform: Apply all migrations: admin, auth, contenttypes, sessions, submit Running migrations: No migrations to apply. ``` @FedorSoldatkin – Hemant joe Oct 06 '20 at 04:16
  • Edit: Now if I enter data in the database, the change and value is being reflected in the admin panel. But still I'm not able to dynamically add value to the submit via admin panel. – Hemant joe Oct 07 '20 at 04:46

1 Answers1

0

This seems to work for me.. the original answer: https://stackoverflow.com/a/59349457/13732795 But I'll copy paste it here too

  1. Go to the virtual environment and install django@2.1.7 pip install django==2.1.7
  2. Delete the db.sqlite3 file in your root folder.
  3. Create the new db.sqlite3 in your root folder.
  4. Re-run migrations:

python manage.py makemigrations python manage.py migrate