在/ admin /没有名为polls_ChoiceField.urls的模块的ImportError

时间:2014-04-28 15:27:18

标签: django python-2.7

Django 1.6.2 MacOSX 10.9.2 Python 2.7

我最近删除了一个Django应用程序“polls_ChoiceField”,它位于另一个应用程序“民意调查”中,因为我只是用它来测试一些东西。但是,因为我删除它然后它所在的应用程序不再有效。

我通过pyDev包资源管理器删除了该文件。当我同步数据库时,它给了我删除过时内容的选项,我选择了是。

任何人都可以告诉我我必须做些什么来让原来的“民意调查”全部重新开始吗?

相关终端输出

localhost:src brendan$ python manage.py syncdb
Creating tables ...
The following content types are stale and need to be deleted:

    polls | choice_choicefield
    polls | poll_choicefield

Any objects related to these content types by a foreign key will also
be deleted. Are you sure you want to delete these content types?
If you're unsure, answer 'no'.

    Type 'yes' to continue, or 'no' to cancel: yes
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)

然后我同步了数据库

localhost:src brendan$ python manage.py syncdb
Creating tables ...
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)

我可以运行服务器

localhost:src brendan$ python manage.py runserver
Validating models...

0 errors found

当我尝试在浏览器中重新访问该应用时,我

ImportError at /polls/

No module named polls_ChoiceField.urls

Request Method:     GET
Request URL:    http://localhost:8000/polls/
Django Version:     1.6.2
Exception Type:     ImportError
Exception Value:    

No module named polls_ChoiceField.urls

Exception Location:     /Library/Python/2.7/site-packages/django/utils/importlib.py in import_module, line 40
Python Executable:  /Library/Frameworks/Python.framework/Versions/2.7/Resources/Python.app/Contents/MacOS/Python
Python Version:     2.7.6
Python Path:    

['/Users/brendan/Dropbox/workspace/bias_experiment/src',
 '/Library/Python/2.7/site-packages/distribute-0.7.3-py2.7.egg',
 '/Library/Python/2.7/site-packages/setuptools-2.2-py2.7.egg',
 '/Library/Python/2.7/site-packages/pip-1.5.4-py2.7.egg',
 '/Library/Python/2.7/site-packages/yolk-0.4.3-py2.7.egg',
 '/Library/Python/2.7/site-packages/virtualenv-1.11.4-py2.7.egg',
 '/Library/Python/2.7/site-packages/virtualenvwrapper-4.2-py2.7.egg',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python27.zip',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-darwin',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/plat-mac/lib-scriptpackages',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-tk',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-old',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/lib-dynload',
 '/Library/Frameworks/Python.framework/Versions/2.7/lib/python2.7/site-packages',
 '/Library/Python/2.7/site-packages']

Server time:    Mon, 28 Apr 2014 16:26:46 +0100

由于

修改 我的urls.py包含错误的代码行(中间网址)

urlpatterns = patterns('',
    url(r'^polls/', include('polls.urls', namespace="polls")),
    url(r'^polls_ChoiceField/', include('polls_ChoiceField.urls', namespace="polls_ChoiceField")),
    url(r'^admin/', include(admin.site.urls)),
)

再次感谢。

1 个答案:

答案 0 :(得分:3)

检查您的项目级urls.py,看起来仍然尝试使用已删除的应用中的urls