本文介绍了Django:错误:未知命令:'makemigrations'的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试遵循 Django 教程,当我输入 python manage.py makemigrations polls

I am trying to follow the Django tutorial and I faced the following error when I enter python manage.py makemigrations polls

Unknown command: 'makemigrations'

这是本教程的,我完成了所有以前的步骤成功,我不知道现在发生了什么或如何解决它。
PS:我已经在INSTALLED_APPS!中包含了投票!

Here's the link to the tutorial and I accomplished all the previous steps successfully and I am not sure what's going wrong now or how to fix it.P.S.: I have already included "polls" in the INSTALLED_APPS!

INSTALLED_APPS = (
    'django.contrib.admin',
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    'polls',
    'South',
)

答案:我不得不修改INSTALLED_APPS到:

Answer: I had to modify INSTALLED_APPS to :

INSTALLED_APPS = (
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        'polls',
    )

并使用此命令: python manage.py syncdb

推荐答案

迁移是第一个版本1.7中添加,于2014年9月2日正式发布。您需要确保您的教程与您正在使用的Django版本相匹配。例如,本版本的教程涵盖1.9:

Migrations were first added in version 1.7, officially released on September 2, 2014. You need to make sure your tutorial matches the version of Django you're working with. For instance, this version of the tutorial covers 1.9:

或者,如果你是使用旧版本的Django,您可以将该网址中的1.9更改为您所使用的任何版本(返回1.3)。或者使用文档页面上的下拉列表选择版本并搜索教程。

Or, if you're using an older version of Django, you can change the "1.9" in that URL to whatever version you're on (back to 1.3). Or use the dropdown on the docs page to pick the version and search for "tutorial".

这篇关于Django:错误:未知命令:'makemigrations'的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持!

07-23 12:24