2
django url patterns do not capture the query string:
The URLconf searches against the requested URL, as a normal Python
string. This does not include GET or POST parameters, or the domain
name.For example, in a request to http://www.example.com/myapp/, the
URLconf will look formyapp/
.In a request to http://www.example.com/myapp/?page=3, the URLconf will
look formyapp/
.The URLconf doesn’t look at the request method. In other words, all
request methods –POST
,GET
,HEAD
, etc. – will be routed to the same
function for the same URL.
So, with that in mind, your url pattern should be:
url(r'^user/account/$', useraccount),
In your useraccount
method:
def useraccount(request):
user_id = request.GET.get('id')
status = request.GET.get('status')
if user_id and status:
# do stuff
else:
# user id or status were not in the querystring
# do other stuff
0
Querystring params and django urls pattern are not the same thing.
so, using django urls pattern:
your url:
http://example.com/user/account/USR1045/1
urls.py
url(r'^user/account/(?P<id>\w+)/(?P<status>\d+)/$', views.useraccount)
views.py
def useraccount(request, id, status):
- [Answered ]-Django catch exception in view and redirect
- [Answered ]-Connect Django 1.11 to Mariadb Galera cluster
- [Answered ]-Django 1.8 – 'NoneType' object has no attribute 'aggregate'
- [Answered ]-Custom User profile for Django user
- [Answered ]-Get A 404 Page when trying to access localhost:8000/accounts/login/ using Django-allauth
Source:stackexchange.com