Re: url pattern matching

36 views
Skip to first unread message

Larry Martell

unread,
Sep 21, 2012, 10:32:52 AM9/21/12
to django...@googlegroups.com
On Fri, Sep 21, 2012 at 10:27 AM, Brian Patterson <bfpat...@gmail.com> wrote:
> Hi Everyone,
> I'm very new to Django and just trying to explore the basics. I'm having a
> problem with the url pattern matching. If i go to site:
> http://mysite:8000/paperforms/
>
> I get the following error:
>
> Using the URLconf defined in mysite.urls, Django tried these URL patterns,
> in this order:
>
> ^admin/
> ^paperforms/ ^paperforms/$
> ^paperforms/ ^paperforms/(?P<checkrequest_id>\d+)/$
> ^paperforms/ ^paperforms/(?P<checkrequest_id>\d+)/results/$
> ^paperforms/ ^paperforms/(?P<checkrequest_id>\d+)/vote/$
> ^paperforms/ ^admin/
>
> The current URL, paperforms/, didn't match any of these.
>
> Shouldn't it find a match on line # 2.

You need an entry that has:

^paperforms/$

Brian Patterson

unread,
Sep 21, 2012, 10:42:04 AM9/21/12
to django...@googlegroups.com
Thanks Larry,
This is what my urls.py file looks like:

from django.conf.urls.defaults import *

from django.contrib import admin
admin.autodiscover()

urlpatterns = patterns('paperforms.views',
'IS THIS THE LINE I SHOULD MODIFY?
  url(r'^paperforms/$', 'index'),
  url(r'^paperforms/(?P<checkrequest_id>\d+)/$', 'detail'),
  url(r'^paperforms/(?P<checkrequest_id>\d+)/results/$', 'results'),
  url(r'^paperforms/(?P<checkrequest_id>\d+)/vote/$', 'vote'),
)

urlpatterns += patterns('',
                        url(r'^admin/', include(admin.site.urls)),
)

Stephen Anto

unread,
Sep 21, 2012, 11:16:44 AM9/21/12
to django...@googlegroups.com
Hi

url('^paperforms/$',                            'view.methods',                         name='paperforms'),
url('^paperforms/(\w+)/$',                    'view.methods',                         name='paperforms_with_arguments'),

It will work if you make your urls like this

thanks for your help. 

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



--
Thanks & Regards
Stephen S



Blog:      blog.f2finterview.com

Reply all
Reply to author
Forward
0 new messages