Найти - Пользователи
Полная версия: Не работает пример из книги Django Разработка веб-приложений на python
Начало » Django » Не работает пример из книги Django Разработка веб-приложений на python
1
petryk
Доброго времени суток!

Выполняю пример из главы 2.

В админку заходит нормально, но когда дело доходит до блога, выдает следующий выхлоп:

Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/blog
Using the URLconf defined in mysite.urls, Django tried these URL patterns, in this order:
^blog/
^admin/doc/
^admin/
The current URL, blog, didn't match any of these.
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.

Пример выполнил один-в-один как в книге, проверил все 10 раз. Что не так, может быть в книге опечатка.

На всякий привожу содержимое файла mysite\urls.py

from django.conf.urls.defaults import patterns, include, url

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
# Examples:
# url(r'^$', ‘mysite.views.home’, name='home'),
url(r'^blog/', include('mysite.blog.urls')),

# Uncomment the admin/doc line below to enable admin documentation:
url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
)

и файла \mysite\blog\urls.py

from django.conf.urls.defaults import *
from mysite.blog.views import archive

urlpatterns = patterns('',
url('r^$', archive),
)
JOHN_16
petryk
оффтоп: оборачивайте код в теги code в квадратных скобках

Вы вообще читали что вам пишут то?
Вам сообщили:
petryk
The current URL, blog, didn't match any of these.
т.е. у вас в файле urls.py нету совпадения с запросом.

А ошибка у вас вот в чем:
petryk
url('r^$', archive),
А надо так:
url(r'^$', archive),





petryk
Спасибо.
This is a "lo-fi" version of our main content. To view the full version with more information, formatting and images, please click here.
Powered by DjangoBB