Django Polls Tutorial No changes detected in app polls

元气小坏坏 提交于 2019-12-23 13:39:09

问题


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 https://docs.djangoproject.com/en/1.7/intro/tutorial01/

Instead, I get

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

回答1:


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.



来源:https://stackoverflow.com/questions/24969471/django-polls-tutorial-no-changes-detected-in-app-polls

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!