没有名为'polls.apps.PollsConfigdjango'的模块; Django项目教程2
所以,我一直在这里按照教程步骤https://docs.djangoproject.com/en/1.9/intro/tutorial02/和我到了我应该运行此命令的步骤:
python manage.py makemigrations polls
当我运行它时,我得到这个错误:
python manage.py makemigrations polls
Traceback (most recent call last):
File "<frozen importlib._bootstrap>", line 2218, in_find_and_load_unlocked
AttributeError: 'module' object has no attribute '__path__'
During handling of the above exception, another exception occurred:
Traceback (most recent call last):
File "manage.py", line 10, in <module>
execute_from_command_line(sys.argv)
File "/home/tgumm/pythonenv/tutorial/lib/python3.4/site-packages/django/core/management/__init__.py", line 353, in execute_from_command_line
utility.execute()
File "/home/tgumm/pythonenv/tutorial/lib/python3.4/site-packages/django/core/management/__init__.py", line 327, in execute
django.setup()
File "/home/tgumm/pythonenv/tutorial/lib/python3.4/site-packages/django/__init__.py", line 18, in setup
apps.populate(settings.INSTALLED_APPS)
File "/home/tgumm/pythonenv/tutorial/lib/python3.4/site-packages/django/apps/registry.py", line 85, in populate
app_config = AppConfig.create(entry)
File "/home/tgumm/pythonenv/tutorial/lib/python3.4/site-packages/django/apps/config.py", line 116, in create
mod = import_module(mod_path)
File "/home/tgumm/pythonenv/tutorial/lib/python3.4/importlib/__init__.py", line 109, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_and_load
File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked
File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed
File "<frozen importlib._bootstrap>", line 2254, in _gcd_import
File "<frozen importlib._bootstrap>", line 2237, in _find_an``d_load
File "<frozen importlib._bootstrap>", line 2221, in _find_and_load_unlocked
ImportError: No module named 'polls.apps.PollsConfigdjango'; 'polls.apps' is not a package
这是我的模特:
from django.db import models
# Create your models here.
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)
第一个问题是回溯中的警告:
No module named 'polls.apps.PollsConfigdjango'
这意味着您在INSTALLED_APPS
设置中的'polls.apps.PollsConfig
后缺少逗号。 它应该是:
INSTALLED_APPS = (
...
'polls.apps.PollsConfig',
'django....',
...
)
第二个问题是警告'polls.apps' is not a package
。 这表明你已经安装了Django 1.8,但你正在关注Django 1.9教程。
如果您使用的是Django 1.8,请遵循1.8教程,以免出现像这样的问题。 在Django 1.8教程中介绍将调查应用添加到INSTALLED_APPS
。 请注意,它不使用PollsConfig
。
INSTALLED_APPS = (
...
'polls',
)
在'polls.apps.PollsConfigdjango'之后检查逗号“,”
ImportError: No module named 'polls.apps.PollsConfigdjango'
你忘了在列表中添加','
链接地址: http://www.djcxy.com/p/86477.html上一篇: No module named 'polls.apps.PollsConfigdjango'; Django project tutorial 2