2015-12-25 2 views
1

Я только начал свое путешествие с Django, и я не могу понять, что я сделал не так. Извините за этот простой вопрос.Django Python Страница не найдена (404)

ИНЗ/urls.py

urlpatterns = [ 
url(r'', include('planner.urls')), 
url(r'^admin/', include(admin.site.urls)),] 

планировщик/urls.py

urlpatterns = [ 
url(r'^$', views.main_page), 
url(r'^/student/$', views.student, name='student'),] 

И мой HREF в base.html:

<a href="/student/">Student</a> 

И моя ошибка:

Request URL: http://127.0.0.1:8000/student/ Using the URLconf defined in inz.urls, Django tried these URL patterns, in this order: ^$ ^/student/$ [name='student'] ^admin/ The current URL, student/, didn't match any of these.

ответ

3

Снимите ведущую косую черту из ^/student/$:

url(r'^student/$', views.student, name='student'), 

FYI, в URL-диспетчерских документы есть related example:

There’s no need to add a leading slash, because every URL has that. For example, it’s ^articles , not ^/articles .

+0

Он работает. Благодаря! – kkkkk

+0

Это правильно. Не нужно добавлять косые черты после r '^ –

Смежные вопросы