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.
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.
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.
[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