Django isn't able to guess you want your polls urls under a /poll/ path.

To achieve this, you do url inclusion

you define something like polls/urls.py like you did and then do

url(r'^polls/', include('polls.urls'))

then your defined urls will work when prepended with a polls/ path.
You can change that polls to foo, and then the same views will work
under 'foo/' path (localhost:8000/foo/1/results will show the results
for poll#1 and so on)

On Sun, Jul 8, 2012 at 3:21 PM, Seyfullah Tıkıç <[email protected]> wrote:
> Yes, in tutorial it is said to be done so. I expect it works as follows,
> after the commented lines.
> 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')),
>     url(r'^(?P<pk>\d+)/$',
>         DetailView.as_view(
>             model=Poll,
>             template_name='polls/detail.html')),
>     url(r'^(?P<pk>\d+)/results/$',
>         DetailView.as_view(
>             model=Poll,
>             template_name='polls/results.html'),
>         name='poll_results'),
>     url(r'^(?P<poll_id>\d+)/vote/$', 'polls.views.vote'),
> )
> urlpatterns += patterns('',
>     url(r'^admin/', include(admin.site.urls)),
>
> 2012/7/8 Mario Gudelj <[email protected]>
>>
>> But you've commented out all your URLs that start with /polls/, like
>> url(r'^polls/$', 'index')... r'^polls/$' will resolve to
>> http://127.0.0.1:8000/polls/, for example.
>>
>> -m
>>
>>
>> On 8 July 2012 23:01, Seyfullah Tıkıç <[email protected]> wrote:
>>>
>>> http://127.0.0.1:8000/polls/34/
>>> http://127.0.0.1:8000/polls/
>>> http://127.0.0.1:8000/polls/34/results/
>>> 2012/7/8 Mario Gudelj <[email protected]>
>>>>
>>>> Which url are you trying to access when you get that 404?
>>>>
>>>> On Jul 8, 2012 5:36 PM, "Seyfullah Tıkıç" <[email protected]> wrote:
>>>>
>>>> --
>>>> You received this message because you are subscribed to the Google
>>>> Groups "Django users" group.
>>>> To post to this group, send email to [email protected].
>>>> To unsubscribe from this group, send email to
>>>> [email protected].
>>>> For more options, visit this group at
>>>> http://groups.google.com/group/django-users?hl=en.
>>>
>>>
>>>
>>>
>>> --
>>> SEYFULLAH TIKIÇ
>>>
>>> --
>>> You received this message because you are subscribed to the Google Groups
>>> "Django users" group.
>>> To post to this group, send email to [email protected].
>>> To unsubscribe from this group, send email to
>>> [email protected].
>>> For more options, visit this group at
>>> http://groups.google.com/group/django-users?hl=en.
>>
>>
>> --
>> You received this message because you are subscribed to the Google Groups
>> "Django users" group.
>> To post to this group, send email to [email protected].
>> To unsubscribe from this group, send email to
>> [email protected].
>> For more options, visit this group at
>> http://groups.google.com/group/django-users?hl=en.
>
>
>
>
> --
> SEYFULLAH TIKIÇ
>
> --
> You received this message because you are subscribed to the Google Groups
> "Django users" group.
> To post to this group, send email to [email protected].
> To unsubscribe from this group, send email to
> [email protected].
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.



-- 
"The whole of Japan is pure invention. There is no such country, there
are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny
(")_(") to help him gain world domination.

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

Reply via email to