Django投票教程在应用程序轮询中未检测到任何更改

编程入门 行业动态 更新时间:2024-10-17 11:30:26
本文介绍了Django投票教程在应用程序轮询中未检测到任何更改的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧! 问题描述 我正在通过Django投票教程,我正在尝试命令python manage.py makemigrations polls,并且我不断收到消息app中没有检测到任何更改

我不明白我做错了什么,或者我可以做的不一样,甚至是什么信息。

编辑清楚:

我希望有些像本教程中的打印输出:

code>民意调查的迁移: 0001_initial.py: - 创建模型问题 - 创建模型选择

然后在本教程中,当它请求我输入命令 python manage.py sqlmigrate polls 0001 时,我得到一些打印输出,像显示的(这是相当长的)。我正在 docs.djangoproject/en/ 1.7 / intro / tutorial01 /

相反,我得到

CommandError:找不到迁移匹配'polls'表单应用程序'0001'。是否在INSTALLED_APPS?

解决方案

问题最终是models.py wasn' t在迁移前填写。它应该是这样的。

models.py 文件:

$ $ $ $ $ $ $ $ $ $ $ $ $ $ class问题(models.Model): question_text = models.CharField(max_length = 200) pub_date = models .DateTimeField('date published') class Choice(models.Model): question = models.ForeignKey(Question) choice_text = models.CharField max_length = 200) vote = models.IntegerField(default = 0)

还要确定'polls.py'列在'settings.py'文件的'INSTALLED_APPS'中。

I'm going through the Django Polls tutorial, and I'm trying the command "python manage.py makemigrations polls", and I keep getting the message "No changes detected in app 'polls'"

I don't understand what I'm doing wrong or how I could do it differently, or what the message even means.

EDIT for clarity:

I expect something somewhat like the printout on the tutorial:

Migrations for 'polls': 0001_initial.py: - Create model Question - Create model Choice

And then later in the tutorial, when it requests I type the command python manage.py sqlmigrate polls 0001, that I get some sort of printout like the one shown (which is rather long). I'm working off the tutorial at docs.djangoproject/en/1.7/intro/tutorial01/

Instead, I get

CommandError: Cannot find a migration matching 'polls' form app '0001'. Is it in INSTALLED_APPS?

解决方案

The issue ended up being that models.py wasn't filled out before the migration. It should look like this.

models.py file:

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) choice_text = models.CharField(max_length=200) votes = models.IntegerField(default=0)

Also be sure that 'polls' is listed in the 'INSTALLED_APPS' of your 'settings.py' file.

更多推荐

Django投票教程在应用程序轮询中未检测到任何更改

本文发布于:2023-07-14 10:06:07,感谢您对本站的认可!
本文链接:https://www.elefans.com/category/jswz/34/1104050.html
版权声明:本站内容均来自互联网,仅供演示用,请勿用于商业和其他非法用途。如果侵犯了您的权益请与我们联系,我们将在24小时内删除。
本文标签:应用程序   检测到   中未   教程   Django

发布评论

评论列表 (有 0 条评论)
草根站长

>www.elefans.com

编程频道|电子爱好者 - 技术资讯及电子产品介绍!