ich habe am Wochenende begonnen mich mit Python und Django zu beschäftigen. Die Installation war recht einfach und danach habe ich mich gleich dem offiziellem Einstiegstutorial (https://docs.djangoproject.com/en/dev/intro/) gewidmet. Heute bin ich fertig geworden,....leider bekomme ich nur noch eine Fehlermeldung, egal welche Seite angezeigt werden soll.
Fehler:
Code: Alles auswählen
Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/polls/1
Using the URLconf defined in Pools.urls, Django tried these URL patterns, in this order:
^$ [name='index']
^(?P<pk>\d+)/$ [name='detail']
^(?P<pk>\d+)/results/$ [name='results']
^(?P<poll_id>\d+)/vote/$ [name='vote']
The current URL, polls/1, didn't match any of these.
Code: Alles auswählen
from django.conf.urls import patterns, url
from django.views.generic import DetailView, ListView
from polls.models import Poll
urlpatterns = patterns('',
url(r'^$',
ListView.as_view(
queryset=Poll.objects.order_by('-pub_date')[:5],
context_object_name='latest_poll_list',
template_name='polls/index.html'),
name='index'),
url(r'^(?P<pk>\d+)/$',
DetailView.as_view(
model=Poll,
template_name='polls/detail.html'),
name='detail'),
url(r'^(?P<pk>\d+)/results/$',
DetailView.as_view(
model=Poll,
template_name='polls/results.html'),
name='results'),
url(r'^(?P<poll_id>\d+)/vote/$', 'polls.views.vote', name='vote'),
)
Peter