I'm trying to write a simple Django app and I have encountered a few
problems handling URL patterns. Any help will be appricated.
Problem 1
____________
My first problem is that I would like to parse a url that is known up until
the last part of the URL. So for example, if I use the following pattern:
*urlpatterns = [ *
* url(r'^blank/$', views.Blank, name='blank'),*
*]*
I can submit the following URL on my browser and the 'Blank' view will be
displayed. No other URL will work with this pattern.
If I use the following pattern:
*urlpatterns = [ *
* url(r'^blank.*/$', views.Blank1, name='blank1'),*
*]*
If I enter:
localhost:8000/uA/blank/
or:
localhost:8000:/uA/blankdlkfajdf/
either pattern will match and the 'Blank1' view gets invoked. I can enter
any URL that starts with /uA/blank, thanks to the '.*' in the pattern.
But if I use the pattern:
*urlpatterns = [ *
* url(r'^blank/.*$', views.BlankMore, name='blankMore'),*
*]*
I can enter:
localhost:8000/uA/blank/
and the pattern will match, but if I enter:
localhost:8000/uA/blank/abc
I get an error message: "Page not found (404)"
I could be doing something wrong here, however I am more inclined to
believe this is a bug. My error? Bug?
Problem 2 - Similar to problem 1 except I would like to capture a value in
the URL
If I use the pattern:
*urlpatterns = [ *
* url(r'^pass/val(?P<val>.*)/$', views.PassVal, name='passval'),*
*]*
and I enter the url:
http://localhost:8000/uA/pass/val12/
the browser displays the value for 'val' as 12.
But if I use a url pattern like this:
*urlpatterns = [ *
* url(r'^pass/(?P<val>.*)/$', views.PassVal, name='passval'),*
*]*
and I enter the url:
http://localhost:8000/uA/pass/val12/
the browser displays the value 'val12', as expected.
but if I enter the url:
http://localhost:8000/uA/pass/?abc=12/
I get an error message: "Page not found (404)"
What I would like to happen in this case is that the value "?abc=12" be
passed to the view. I know the '?' is a special character here but not to
the browser or Django. My expectation is that the browser would pass it as
part of the request and that Django would do likewise. Is this a bug? My
error?
Jim A.
--
You received this message because you are subscribed to the Google Groups
"Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email
to [email protected].
To post to this group, send email to [email protected].
Visit this group at https://groups.google.com/group/django-users.
To view this discussion on the web visit
https://groups.google.com/d/msgid/django-users/eecbab47-35d7-4f58-909e-175ca6f76eea%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.