title: Decorator overwriting POST, GET and REQUEST in Django - doing it right?
body: <p>In Django, I have created a function decorator which can - in this example - create a lowercase version of a supplied POST/GET argument, and it updates the REQUEST before the view handles it all. 
  I have created the following decorator for this:</p>
  
  <pre><code>def force_lowercase(*fields):
      assert isinstance(fields, tuple), "Fields must be of type tuple."
  
      def wrap_func(fn):
         def wrapper(request):
             post = request.POST.copy()
             get  = request.GET.copy()
             for field in fields:
                 if field in post:
                     post[field] = post[field].lower()
                 if field in get:
                     get[field]  = get[field].lower()
  
             request._post = post   
             request._get = get
             request._request = MergeDict(post,get)
  
             return fn(request)
         return wrapper
     return wrap_func
  </code></pre>
  
  <p>In my view I would have something like:</p>
  
  <pre><code>@force_lowercase(email,zipcode)
  def index(request)
      #blabla
  </code></pre>
  
  <p>Is this the proper way to do this? I'm a bit concerned I hack Django's WSGIRequest object in such a way, other Django functionality might not see the updated GET/POST/REQUEST objects.</p>