Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

change request.GET QueryDict values

I want to change request.GET querydict object in django. I tried this but changes made by me are not reflected. I tried this

tempdict = self.request.GET.copy() # Empty initially
tempdict['state'] = ['XYZ',]
tempdict['ajaxtype'] = ['facet',]
print self.request.GET

I get

<QueryDict: {}> as my output

Is it possible to change the request.GET querydict object in django?

like image 570
Anurag Sharma Avatar asked Oct 08 '13 11:10

Anurag Sharma


1 Answers

You can't change the request.GET or request.POST as they are instances of QueryDict which are immutable according to the docs:

QueryDict instances are immutable, unless you create a copy() of them. That means you can’t change attributes of request.POST and request.GET directly.

like image 156
Timmy O'Mahony Avatar answered Oct 13 '22 01:10

Timmy O'Mahony