Python Django没有名为' app'在eclipse中,urls.py

时间:2017-02-11 02:35:41

标签: python django eclipse

我收到此错误消息。它似乎无法识别应用程序。难道没有办法解决这个问题吗?

错误消息。

pydev debugger: starting (pid: 5628)
pydev debugger: starting (pid: 3504)
Performing system checks...

Unhandled exception in thread started by <_pydev_bundle.pydev_monkey._NewThreadStartupWithTrace instance at 0x0478C210>
 Traceback (most recent call last):
 File "C:\Users\jeon hyun joo\.p2\pool\plugins\org.python.pydev_5.5.0.201701191708\pysrc\_pydev_bundle\pydev_monkey.py", line 574, in __call__
return self.original_func(*self.args, **self.kwargs)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\django\utils\autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\django\core\management\commands\runserver.py", line 121, in inner_run
self.check(display_num_errors=True)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\django\core\management\base.py", line 374, in check
include_deployment_checks=include_deployment_checks,
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\django\core\management\base.py", line 361, in _run_checks
return checks.run_checks(**kwargs)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\django\core\checks\registry.py", line 81, in run_checks
new_errors = check(app_configs=app_configs)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\django\core\checks\urls.py", line 14, in check_url_config
return check_resolver(resolver)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\django\core\checks\urls.py", line 24, in check_resolver
for pattern in resolver.url_patterns:
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\django\utils\functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\django\urls\resolvers.py", line 313, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\django\utils\functional.py", line 35, in __get__
res = instance.__dict__[self.name] = self.func(instance)
File "C:\Python27\lib\site-packages\django-1.10.5-py2.7.egg\django\urls\resolvers.py", line 306, in urlconf_module
return import_module(self.urlconf_name)
File "C:\Python27\lib\importlib\__init__.py", line 37, in import_module
__import__(name)
File "C:\Users\jeon hyun joo\workspace\blog\blog\blog\urls.py", line 19, in <module>
from blog.polls import views
ImportError: No module named polls

似乎urls.py中存在问题,但我无法找到导致此问题的部分。

urls.py

from django.conf.urls import url
from django.contrib import admin

from blog.polls import views


urlpatterns = [
url(r'^admin/', admin.site.urls),
url(r'^polls/(?P<question_id>\d+)$', views.detail, name='detail'),
url(r'^polls/(?P<question_id>\d+)/vote/$', views.vote, name='vote'),
url(r'^polls/(?P<question_id>\d+)/results/$', views.results, name='results'),]

我添加了项目结构。

blog
  └── blog
        ├── blog
        │    ├── __init__.py
        │    ├── settings.py
        │    ├── urls.py
        │    └── wsgi.py
        │  
        ├── polls
        │    ├── migrations
        │    ├── __init__.py
        │    ├── admin.py
        │    ├── apps.py
        │    ├── detail.html
        │    ├── index.html
        │    ├── models.py
        │    ├── results.html
        │    ├── tests.py
        │    └── views.py
        └── manage.py 

1 个答案:

答案 0 :(得分:0)

我刚刚解决了这个问题。我想它找不到应用程序的原因是因为有很多同名的东西。我重命名了项目名称和应用名称并解决了问题。