How to run Django migrations in Visual Studio 2022 - Stack Overflow

I have created a Django project in my Visual Studio solution. The db.sqlite3 file was also created. The

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

发布者:admin,转转请注明出处:http://www.yc00.com/questions/1744036572a4547530.html

相关推荐

  • How to run Django migrations in Visual Studio 2022 - Stack Overflow

    I have created a Django project in my Visual Studio solution. The db.sqlite3 file was also created. The

    13小时前
    10

发表回复

评论列表(0条)

  • 暂无评论

联系我们

400-800-8888

在线咨询: QQ交谈

邮件:admin@example.com

工作时间:周一至周五,9:30-18:30,节假日休息

关注微信