Search
 
SCRIPT & CODE EXAMPLE
 
CODE EXAMPLE FOR PYTHON

querydict instance is 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
<QueryDict: {}>
>>> request.GET['foo'] = 'bar'
AttributeError: This QueryDict instance is immutable
>>> request.GET = request.GET.copy()
<QueryDict: {}>
>>> request.GET['foo'] = 'bar'
>>> request.GET
<QueryDict: {'foo': 'bar'}>
Source by stackoverflow.com #
 
PREVIOUS NEXT
Tagged: #querydict #instance #immutable
ADD COMMENT
Topic
Name
3+7 =