How to run Django migrations in Visual Studio 2022
I have created a Django
project in my Visual Studio solution. The db.sqlite3
file was also created. There are a few classes in models.py
.
class Question(models.Model):
q_id = models.IntegerField()
text = models.CharField(max_length=500)
class Option():
option_num = models.IntegerField()
text = models.CharField(max_length=1000)
When I right click on the project, there are these options - Make Migrations, Migrate & Create Superuser.
When I execute Django Make Migrations
, in the terminal it says Executing manage.py makemigrations
, but nothing happens.
Then I execute Migrate
. It says, a command is already running.
The __init__.py
isn't updated.
I also tried, executing this command in VS Terminal, but there is no response.
python manage.py makemigrations
From your code below, the Option class is not inheriting from models.Model as you'd in the Question above.
py
class Option(models.Model):
option_num = models.IntegerField()
text = models.CharField(max_length=1000)
Looking at you app level migrations folder, I can't actually see the __init__.py
. Please ensure it is there and at the app directory root.
Once you are done with the above changes, you can now run the following commands sequentially on your terminal;
bash
python manage.py makemigrations
python manage.py migrate
python manage.py runserver