Well, I was folloging Django Girls Tutorial but using django version 4.2 All was right until I need makemigrations when I created the model.
I put the new app "blog" on INSTALLED_APPS in settings.py:
INSTALLED_APPS = [
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog',
]
Also, I don't think is necessary, but added the register on admin.py:
from django.contrib import admin
from .models import Post
admin.site.register(Post)
After adding all this content and installation, I need to execute makemigrations to generate the 0001_initial.py file migration inside ./blog/migrations directory, but it says me the following message:
No changes detected
Included the name of my app after the makemigrations command, and still changes were not detected
I searched this error on internet and tried different migrate variations, but the only one that worked for me was the next one>
./manage.py migrate --run-syncdb
Then it worked, I'm using the default django SGDB sqlite3, the database tables were created after this command and after running the server I can use the models as normal.
The problem of doing this comes when I want to edit the models, I execute makemigrations and it still doesn't detect changes. The previous command --run-syncdb only works for creating the database but cannot update with the new models fields.
I can tell the problem is from Django 4.2 because I followed the same exact steps on three different computers with Ubuntu, Termux and Windows each one.
Also I tried the same tutorial with Django 3.2 and had not any problems on migrations or database creation.
Try this
Like this :