So, I've been following the tutorial steps here https://docs.djangoproject.com/en/1.9/intro/tutorial02/ and I got to the step where I am supposed to run this command:
python manage.py makemigrations polls
When I run it, I get this error:
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
Here are my models:
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)
The first problem is this warning in the traceback:
No module named 'polls.apps.PollsConfigdjango'
That means that you are missing a comma after 'polls.apps.PollsConfig
in your INSTALLED_APPS
setting. It should be:
INSTALLED_APPS = ( ... 'polls.apps.PollsConfig', 'django....', ... )
The second problem is the warning 'polls.apps' is not a package
. That suggests that you have installed Django 1.8, but you are following the Django 1.9 tutorial.
If you are using Django 1.8, then follow the 1.8 tutorial so that you don't hit problems like this. Adding the polls app to INSTALLED_APPS
is covered here in the Django 1.8 tutorial. Note that it doesn't use PollsConfig
.
INSTALLED_APPS = ( ... 'polls', )
ImportError: No module named 'polls.apps.PollsConfigdjango'
You forgot to add ',' in the list
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With