I want to create custom django admin template and pass there some data. Is it possible to access GET query in custom template ?
1 Answer
The request object should be injected into all templates, so yes, you can access the GET dictionary.
{{ request.GET.my_param }}
6 Comments
Alexey K
I try to print out value of get request by creating the following template dropbox.com/s/37o6ywocu3biapj/… . admin form prints out, but my_param - not
Brobin
Can you double check that
'django.template.context_processors.request' is in your TEMPLATE context_processors setting?Brobin
Interesting. And your url has the parameter in it? somehting like this?
/admin/something?my_param=somethingAlexey K
yes, like this 127.0.0.1:8000/admin/core/orderingsettings/?my_param=hello. after request submit it looks like 127.0.0.1:8000/admin/core/orderingsettings/?e=1
Brobin
That is odd. you should be able to access it through
{{ request.GET.e }} |