python manage.py migrate [将新模型添加到数据库]

时间:2016-12-22 20:42:03

标签: python django

我正在djangogirls.org网站上做创建博客的教程。我正在尝试将新模型添加到数据库中,并执行了以下操作:

$ python manage.py makemigrations blog

我得到错误列表:

Traceback (most recent call last):
  File "manage.py", line 22, in <module>
    execute_from_command_line(sys.argv)
  File "/home/marty/swapper/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 367, in execute_from_command_line
    utility.execute()
  File "/home/marty/swapper/venv/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 341, in execute
    django.setup()
  File "/home/marty/swapper/venv/local/lib/python2.7/site-packages/django/__init__.py", line 27, in setup
    apps.populate(settings.INSTALLED_APPS)
  File "/home/marty/swapper/venv/local/lib/python2.7/site-packages/django/apps/registry.py", line 108, in populate
    app_config.import_models(all_models)
  File "/home/marty/swapper/venv/local/lib/python2.7/site-packages/django/apps/config.py", line 199, in import_models
    self.models_module = import_module(models_module_name)
  File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
    __import__(name)
  File "/home/marty/swapper/blog/models.py", line 4, in <module>
    from django.util import timezone
ImportError: No module named util

我被困住了。

1 个答案:

答案 0 :(得分:0)

您有导入错误

from django.util import timezone ImportError: No module named util

更改为:

from django.utils import timezone

在您的博客模型中,它会没问题