我刚刚开始通过Djangoproject的教程学习Django。 我正在尝试迁移,但在应该显示“ Applying polls.0001_initial ... OK”的终端中显示“没有要应用的迁移”。 而且不知道我在哪里犯了错误,请您帮忙吗? 谢谢。
[终端]
Operations to perform:
Apply all migrations: admin, auth, contenttypes, polls, sessions
Running migrations:
No migrations to apply.
[mysite / polls / models.py]
from django.db import models
class Question(models.Model):
question_text = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
class Choice(models.Model):
question = models.ForeignKey(Question, on_delete=models.CASCADE)
choice_text = models.CharField(max_length=200)
votes = models.IntegerField(default=0)
[migrations / 0001_initial.py]
from django.db import migrations, models
import django.db.models.deletion
class Migration(migrations.Migration):
initial = True
dependencies = [
]
operations = [
migrations.CreateModel(
name='Choice',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('choice_text', models.CharField(max_length=200)),
('votes', models.IntegerField(default=0)),
],
),
migrations.CreateModel(
name='Question',
fields=[
('id', models.AutoField(auto_created=True, primary_key=True, serialize=False, verbose_name='ID')),
('question_text', models.CharField(max_length=200)),
('pub_date', models.DateTimeField(verbose_name='date published')),
],
),
migrations.AddField(
model_name='choice',
name='question',
field=models.ForeignKey(on_delete=django.db.models.deletion.CASCADE, to='polls.Question'),
),
]
https://docs.djangoproject.com/en/2.1/intro/tutorial02/
我正在将蟒蛇3.7.2与蟒蛇一起使用。
答案 0 :(得分:0)
听起来可能很蠢,但是您是否刷新了应用程序?我的意思是示例:在文件侧栏上的VSCode上,您可以右键单击并选择刷新,或在“创建文件”选项卡旁边单击“刷新”选项卡。我以前没有显示过我的新迁移,所以不得不刷新以查看它们。