django operational error code example
Example: django operational error
In the case of an Operational Error in django you HAVE TO do the following :-
0) Reload the site
Still not solved
1) Delete the migrations folder and pycache folder
Still not solved
2) Reload the site
2) python manage.py makemigrations, then python manage.py migrate.
3) Reload the site
Still not solved
4) python manage.py makemigrations appNameHere, then python manage.py migrate appNameHere
Still not solved
5) Then reload the site
Still not solved
6) Now, remove the row which was giving you the error, class y(Models.model):
a = models.CharField(default='Let us say default')
b = ....
Yes, remove the one giving you the error, for example, it is saying
OperationalError at /admin/blog/blogpost/ no such column: table_table.a
then remove the thing coming after the dot
a in this case
remove it so that only
b = ....
is left in the model
It is happening because that column was left null. You have to delete the column it self (NOT THE MODEL INSTANCE)
Then once you are able to get in you have to add the field again.
Then you can fill the nulled part up with something
Still not solved
5) Reload the site
The final tip
Reload the site
The problem should be solved!!
Subscribe to GuruTheCoder