Accessing URL Parameters in Django Templates

2,491 views
Skip to first unread message

Sameer Maggon

unread,
Jul 2, 2008, 1:52:41 PM7/2/08
to Django users
Hi All,

Is there a standard way to access the URL parameters in the Django
templates? I can write a template tag to do that, but I was hoping I
could avoid it.

Thanks,
Sameer.
--
http://www.maggon.com

Scott Moonen

unread,
Jul 2, 2008, 1:57:36 PM7/2/08
to django...@googlegroups.com
Sameer, if you are using the RequestContext object to produce the template context, then you should be able to access the URL parameters in your template as request.GET.parametername.  In this case, request.GET is a QueryDict object (see http://www.djangoproject.com/documentation/request_response/#querydict-objects).

  -- Scott
--
http://scott.andstuff.org/ | http://truthadorned.org/

Sameer Maggon

unread,
Jul 2, 2008, 4:06:58 PM7/2/08
to Django users
That worked!

Thanks,
Sameer

On Jul 2, 10:57 am, "Scott Moonen" <smoo...@andstuff.org> wrote:
> Sameer, if you are using the RequestContext object to produce the template
> context, then you should be able to access the URL parameters in your
> template as request.GET.*parametername*.  In this case, request.GET is a
> QueryDict object (seehttp://www.djangoproject.com/documentation/request_response/#querydic...
> ).
Reply all
Reply to author
Forward
0 new messages