[PYTHON] Django novice addicted error and solution notes

What i did

I wanted to make a web application with python, so I tried Udemy Beginner's Course.

It was a course to edit the source with VScode & operate Linux, run the application with Django, and use SQLite for DB.

Development environment

Environment

After building a virtual environment with venv, I installed the Django package, but VScode checked "Unable to Import Django ~".

The Python file referenced by Linter in VScode was different from the one installed in the virtual environment. Can be changed from the settings. The choices are displayed automatically, but you can also specify the directory directly.

Project settings

The image file registered in the app is not saved in the specified directory.

The variable name that should be set as "MEDIA_ROOT" was set as "MEDIA_DIR" in the project settings.py. Completely a mistake.

SQLite When I try to execute the migrate command, it fails with an error saying "There is no model called AAA". However, there is a model called AAA in both models.py and the files under migrations.

I wanted to fix the model name AAA, so I edited the files under migrations directly. After that, because I ran the makemigrations command, I got an error even if I corrected the model name. I'm completely lacking in SQLite knowledge ... I did a lot of research on the countermeasures, but I didn't know, and eventually I recreated the migrations folder.

debug

I should have fixed the source code perfectly, but the error doesn't go away! !! !! !!

About 90% of the files are not saved on VScode. This is also a lack of understanding of the specifications in that area.

Recommended Posts

Django novice addicted error and solution notes
Error classification (python3.x) and Debugging notes
django notes
Django notes
[Django] as_view () notes
Django Template notes
Django2.2 SQLite3 version error
Django settings.py SECRET_KEY error
Celery notes on Django
pytube execution and error
Golang error and panic
Django --models.py and admin.py