admin管理员组

文章数量:1356960

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

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

Share Improve this question asked Mar 28 at 12:56 sukeshsukesh 2,41112 gold badges64 silver badges130 bronze badges
Add a comment  | 

1 Answer 1

Reset to default 0

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

本文标签: How to run Django migrations in Visual Studio 2022Stack Overflow