kkkkk
kkkkk

Reputation: 726

Django Python Page not found (404)

I just started my journey with Django and I can't figure out what I did wrong. Sorry for that simple question.

inz/urls.py

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

planner/urls.py

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

And my href in base.html:

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

And my error:

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.

Upvotes: 1

Views: 166

Answers (1)

alecxe
alecxe

Reputation: 474161

Remove the leading slash from ^/student/$:

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

FYI, in the URL dispatcher docs there is a related example:

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

Upvotes: 3

Related Questions