Tuesday, August 3, 2010

error 404

hi
i don't know why i cant see generic view , please help me .
i have this error


Page not found (404)
Request Method: GET
Request URL: http://127.0.0.1:8000/

Using the URLconf defined in mysite.urls, Django tried these URL
patterns, in this order:

1. ^polls/$
2. ^polls/(?P<poll_id>\d+)/$
3. ^polls/(?P<poll_id>\d+)/results/$
4. ^polls/(?P<poll_id>\d+)/vote/$
5. ^admin/

The current URL, , didn't match any of these.

mysite.urls.py

from django.conf.urls.defaults import *

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('',
(r'^polls/$', 'mysite.polls.views.index'),
(r'^polls/(?P<poll_id>\d+)/$', 'mysite.polls.views.detail'),
(r'^polls/(?P<poll_id>\d+)/results/$',
'mysite.polls.views.results'),
(r'^polls/(?P<poll_id>\d+)/vote/$', 'mysite.polls.views.vote'),
(r'^admin/', include(admin.site.urls)),

)

mysite.polls.urls.py

from django.conf.urls.defaults import *
from mysite.polls.models import Poll

info_dict = {
'queryset': Poll.objects.all(),
}

urlpatterns = patterns('',
(r'^$', 'django.views.generic.list_detail.object_list',
info_dict),
(r'^(?P<object_id>\d+)/$',
'django.views.generic.list_detail.object_detail', info_dict),
url(r'^(?P<object_id>\d+)/results/$',
'django.views.generic.list_detail.object_detail', dict(info_dict,
template_name='polls/results.html'), 'poll_results'),
(r'^(?P<poll_id>\d+)/vote/$', 'mysite.polls.views.vote'),
)

models.py

from django.db import models
import datetime

class Poll(models.Model):
question = models.CharField(max_length=200)
pub_date = models.DateTimeField('date published')
def __str__(self):
return self.question
def was_published_today(self):
return self.pub_date.date() == datetime.date.today()
was_published_today.short_description = 'Published today?'


class Choice(models.Model):
poll = models.ForeignKey(Poll)
choice = models.CharField(max_length=200)
votes = models.IntegerField()
def __str__(self):
return self.choice

admin.py

from mysite.polls.models import Poll
from django.contrib import admin
from mysite.polls.models import Choice

class ChoiceInline(admin.StackedInline):
model = Choice
extra = 3

class PollAdmin(admin.ModelAdmin):
fieldsets = [
(None, {'fields': ['question']}),
('Date information', {'fields': ['pub_date'], 'classes':
['collapse']}),
]
inlines = [ChoiceInline]
list_display = ('question', 'pub_date', 'was_published_today')
list_filter = ['pub_date']
search_fields = ['question']
date_hierarchy = 'pub_date'

admin.site.register(Poll, PollAdmin)
admin.site.register(Choice)


what is my wrong ?

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

No comments:

Post a Comment