8

Looking at dir(request.GET), I notice that pop is listed as a method. I also believe i've popped off attributes from request in the past.

Is that accurate? If so, why would this fail?

request.GET.pop('key')
Ben
  • 15,010
  • 11
  • 58
  • 90

1 Answers1

20

request.GET and request.POST are immutable QueryDict instances. This means you cannot change their attributes directly.

Copying a QueryDict, returns a mutable QueryDict. You can then call the pop method of the copy without raising an error.

request.GET
GET = request.GET.copy()
GET.pop('key')    
Alasdair
  • 298,606
  • 55
  • 578
  • 516