Итак, все шло хорошо, пока я не добрался до части 3. Когда я пытаюсь загрузить http://localhost:8000/lru/ Я получаю следующее сообщение об ошибке:
Код: Выделить всё
AttributeError at /lru/
'module' object has no attribute 'index'
Код: Выделить всё
Internal Server Error: /favicon.ico
Traceback (most recent call last):
File "/Library/Python/2.7/site-packages/django/core/handlers/base.py", line 92, in get_response
response = middleware_method(request)
File "/Library/Python/2.7/site-packages/django/middleware/common.py", line 69, in process_request
if (not urlresolvers.is_valid_path(request.path_info, urlconf) and
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py", line 551, in is_valid_path
resolve(path, urlconf)
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py", line 440, in resolve
return get_resolver(urlconf).resolve(path)
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py", line 319, in resolve
for pattern in self.url_patterns:
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py", line 347, in url_patterns
patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
File "/Library/Python/2.7/site-packages/django/core/urlresolvers.py", line 342, in urlconf_module
self._urlconf_module = import_module(self.urlconf_name)
File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Users/oyvindhellenes/Desktop/Sommerjobb 2013/mysite/mysite/urls.py", line 10, in
url(r'^lru/', include('lru.urls', namespace="lru")),
File "/Library/Python/2.7/site-packages/django/conf/urls/__init__.py", line 25, in include
urlconf_module = import_module(urlconf_module)
File "/Library/Python/2.7/site-packages/django/utils/importlib.py", line 35, in import_module
__import__(name)
File "/Users/oyvindhellenes/Desktop/Sommerjobb 2013/mysite/lru/urls.py", line 6, in
url(r'^$', views.index, name='index')
AttributeError: 'module' object has no attribute 'index'
views.py
Код: Выделить всё
from django.http import HttpResponse
def index(request):
return HttpResponse("Hello, world. You're at the poll index.")
Код: Выделить всё
from django.conf.urls import patterns, url
from lru import views
urlpatterns = patterns('',
url(r'^$', views.index, name='index')
)
Код: Выделить всё
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
url(r'^polls/', include('polls.urls', namespace="polls")),
url(r'^admin/', include(admin.site.urls)),
url(r'^lru/', include('lru.urls', namespace="lru")),
)
Код: Выделить всё
mysite/
lru
templates
polls
manage.py
mysite
lru/
templates
urls.py
admin.py
__init__.py
models.py
tests.py
views.py
Это меня действительно убивает, поэтому любая помощь будет признательна !
Изменить: добавлена полная обратная трассировка
Подробнее здесь: https://stackoverflow.com/questions/178 ... bute-index
Мобильная версия