How to get the current url namespace using Django?

I don’t know how long this feature has been part of Django but as the following article shows, it can be achieved as follows in the view: from django.core.urlresolvers import resolve current_url = resolve(request.path_info).url_name If you need that in every template, writing a template request can be appropriate. Edit: APPLYING NEW DJANGO UPDATE Following the … Read more

Including a querystring in a django.core.urlresolvers reverse() call

You can’t capture GET parameters in the url confs, so your method is correct. I generally prefer string formatting but it’s the same thing. “%s?next=%s” % (reverse(name), reverse(redirect)) http://docs.djangoproject.com/en/dev/topics/http/urls/#what-the-urlconf-searches-against The URLconf searches against the requested URL, as a normal Python string. This does not include GET or POST parameters, or the domain name.

How to get the current url name using Django?

I don’t know how long this feature has been part of Django but as the following article shows, it can be achieved as follows in the view: from django.core.urlresolvers import resolve current_url = resolve(request.path_info).url_name If you need that in every template, writing a template request can be appropriate. Edit: APPLYING NEW DJANGO UPDATE Following the … Read more