I already have a django project and it logical like those:
url: URL?username=name&pwd=passwd
view:
def func(request):
dic = request
django.http.QueryDict objects that are assigned to request.GET and request.POST are immutable.
You can convert it to a mutable QueryDict instance by copying it:
request.GET = request.GET.copy()
Afterwards you'll be able to modify the QueryDict:
>>> from django.test.client import RequestFactory
>>> request = RequestFactory().get('/')
>>> request.GET
>>> request.GET['foo'] = 'bar'
AttributeError: This QueryDict instance is immutable
>>> request.GET = request.GET.copy()
>>> request.GET['foo'] = 'bar'
>>> request.GET
This has been purposefully designed so that none of the application components are allowed to edit the source request data, so even creating a immutable QueryDict again would break this design. I would still suggest that you follow the guidelines and assign additional request data directly on the request object in your middleware, despite the fact that it might cause you to edit your sources.