If you get a Programming Error: (1146, "Table'<table name>' doesn't exist") in Django

Introduction

I am a beginner studying Python etc. with the aim of becoming a backend engineer. Qiita will be the first post.

This time, a title error occurred while deploying the created Django app to AWS EC2. I had a hard time not knowing the cause, so I will write down the solution.

environment

error contents

After setting up Apache and MySQL and running Django's migraion, when I accessed the EC2 public IP address from a browser, the following error was displayed.

Django.db.utils.ProgrammingError: (1146," Table'<table name>' doesn't exist ")

The error is that the table literally doesn't exist.

When I was using SQLite3 locally, it worked, so I wondered if the MySQL settings on the server were wrong and tried various things, but it didn't work ...

So when I looked back at Django's app configuration, I noticed that the migration file that was supposed to be created doesn't exist. It seems that migration is not working well.

Cause and solution

The Django project deployed this time consisted of two apps under one project.

In that case, it seems that migration may not be executed correctly unless you specify the app name such as python3 manage.py makemigraions <app name>.

So this time

python3 manage.py makemigraions <app name> python3 manage.py migrate

When I executed, the table was created and the above error disappeared.

If you are suffering from similar events, please give it a try.

reference

[I created a django model, but makemigrations shows No changes detected | Monotalk] (https://www.monotalk.xyz/blog/django-model-%E3%82%92%E4%BD%9C%E6%88%90%E3%81%97%E3%81%9F%E3%81%8Cmakemigrations-%E3%81%A7-no-changes-detected-%E3%81%AB%E3%81%AA%E3%82%8B/)

Recommended Posts

If you get a Programming Error: (1146, "Table'<table name>' doesn't exist") in Django
If you get Error: That port is already in use. In Django
If you get a no attribute error in boto3, check the version
What to do if you get a "No versions found" error in pipenv
[Python] What to check when you get a Unicode Decode Error in Django
BigQuery-If you get a Reason: responseTooLarge error in Python
If you encounter a "Unicode Decode Error" in Python
Solution if you get 0xxx ascii coding error in superset
What to do if you get a Cannot retrieve metalink for repository error in yum
What to do if you get a minus zero in Python
What to do if you get a must override `get_config` error when trying to model.save in Keras
How to get a namespaced view name from a URL (path_info) in Django
What to do if you get an error when trying to send a message in tasks.loop () immediately after startup
When I get a chromedriver error in Selenium
If you want to display values using choices in a template in a Django model
If you get a long error when tabbing an interactive shell with Anaconda
Until you create a new app in Django
What to do if you get a Call with too many input arguments error at DoAndReturn in a golang test
What to do if you get a memory error when converting from PySparkDataFrame to PandasDataFrame
What to do if you get "(35,'SSL connect error')" in pycurl (one of them)
What to do if you get an error when importing matplotlib in Python (Mac)
If you get the error "basis matrix is singular to working precision" in GLPK
When you get an error in python scraping (requests)
Get a participant's username and screen name in Slack
What to do if you get Swagger-codegen in python and Import Error: No module named
Solution if the module is installed in Python but you get an error in Jupyter notebook
What to do if you get an error when running "certbot renew" in CakePHP environment
Why do you add a main ()-if statement in Python?
What to do if you get "coverage unknown" in Coveralls
What to do if a 0xC0000005 error occurs in tf.train.start_queue_runners ()
What to do if you get angry with'vertices' must be a 2D list ... in matplotlib arrow
Here are some grammars that you might get a slapstick face if you know it in Python
What to do if you get an error saying c compiler cannot create executables in configure
If you are a beginner in programming, why not make a "game" for the time being? The story
If you know Python, you can make a web application with Django
What to do if you get a UnicodeDecodeError with pip install
If you want to assign csv export to a variable in python
Check if you can connect to a TCP port in Python
If you should have pip installed but get an Import error
What to do if you get angry with "Value Error: unknown local: UTF-8" in python manage.py syncdb
What to do if you get a Permission denied (public key) error when trying to pull on Github
[Python] What to do if you get a ModuleNotFoundError when importing pandas using Jupyter Notebook in Anaconda
What to do if you get the error Input contains NaN, infinity or a value too large for dtype ('float64'). In machine learning
What to do if you get the error RuntimeError: Python is not installed as a framework when trying to use matplitlib and pylab in Python 3.3