开发者

Help with "Error: No module named polls" from the Django Project Tutorial 1

I am working on this Django t开发者_如何学运维utorial and am getting this error: "Error: No module named polls" when I type "python manage.py sql polls" in the terminal. I have no clue how to fix this problem. Any help would be greatly appreciated.


INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.messages',
    'django.contrib.staticfiles',
    # Uncomment the next line to enable the admin:
    # 'django.contrib.admin',
    # Uncomment the next line to enable admin documentation:
    # 'django.contrib.admindocs',
    'polls' # THIS IS THE ANSWER
)


There is an error in the documentation. Type polls instead of mysite.polls.


Ismael's answer worked for me.

Originally had

urlpatterns = patterns('',
    (r'^polls/$ ,'mysite.polls.views.index'),
)

Changed to

urlpatterns = patterns('',
    (r'^polls/$ ,'polls.views.index'),
)


If you have added polls app inside the setting.py please remove that and try recreating the polls and then add to the setting.py file. This solved my issue :)

INSTALLED_APPS = (
        'django.contrib.admin',
        'django.contrib.auth',
        'django.contrib.contenttypes',
        'django.contrib.sessions',
        'django.contrib.messages',
        'django.contrib.staticfiles',
        #Remove the below application and try again
        #'polls',
)


It might be possible that you missing "," after 'polls.apps.PollsConfig' in settings.py file


This need to run one command after your changes in INSTALLED_APPS

$ python manage.py makemigrations polls

after that:

$ python manage.py sqlmigrate polls 0001


You must create all these files in pool directory: init.py, admin.py, models.py, tests.py,views.py. succes


Be sure you actually stayed true to the tutorial and named your app "polls", otherwise things won't link up.


Changing from 'polls.app.PollsConfig' to 'polls' worked for me

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜