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
1 Answer
Reset to default 0From 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
版权声明:本文标题:How to run Django migrations in Visual Studio 2022 - Stack Overflow 内容由网友自发贡献,该文观点仅代表作者本人, 转载请联系作者并注明出处:http://www.betaflare.com/web/1744036571a2579880.html, 本站仅提供信息存储空间服务,不拥有所有权,不承担相关法律责任。如发现本站有涉嫌抄袭侵权/违法违规的内容,一经查实,本站将立刻删除。
发表评论