OK, thanks! I won't use it for this specific case, but I'm sure it will be extremely helpful in the future. The logic you've shown can be applied in other different contexts.
Andrea 2014-07-25 17:49 GMT+02:00 Tom Evans <tevans...@googlemail.com>: > On Fri, Jul 25, 2014 at 4:00 PM, Andrea <andrea.g...@gmail.com> wrote: > > Thanks Tom, now I see your point. > > As my API was crafted on the previous version of Datatables, and used > only > > for that purpose, I prefer just to replace it with the new one. > > Had I already an API for whatever reason, I see the usefulness and the > > importance of your approach. I understand the logic, but I'm still not > sure > > how I could code it. > > > > The QueryDict you point out is in my case `request.GET`. > > > > new_request_get = QueryDict(mutable=True) > > new_request_get['new_key'] = request.GET['old_key'] > > # ... > > # Set perhaps mutable=False > > form = DataTablesForm(new_request_get) > > > > Is what you mean something like that? > > > > Thanks, > > Andrea > > Yep but happening inside the form itself. Eg: > > class MyForm(Form): > def __init__(self, *args, **kwargs): > data =kwargs.get('data') > if data: > new_data = QueryDict(mutable=True) > new_data[...] = .... > ... > kwargs['data'] = new_data > super(MyForm, self).__init__(*args, **kwargs) > > view: > > form = MyForm(data=request.POST) > > Then, anywhere you use the form it has the logic to process the data > correctly without polluting the view. > > Cheers > > Tom > > -- > You received this message because you are subscribed to the Google Groups > "Django users" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to django-users+unsubscr...@googlegroups.com. > To post to this group, send email to django-users@googlegroups.com. > Visit this group at http://groups.google.com/group/django-users. > To view this discussion on the web visit > https://groups.google.com/d/msgid/django-users/CAFHbX1LU2BNXumk7vFG%3Di5r-J%3Dw8xBm%2BG6qvrRjYW247EitEOw%40mail.gmail.com > . > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to django-users+unsubscr...@googlegroups.com. To post to this group, send email to django-users@googlegroups.com. Visit this group at http://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAAPQ7Y26t92C9DshbJnhOLvhd5Yscwmf5TgVOGRN6TVh0OFA6A%40mail.gmail.com. For more options, visit https://groups.google.com/d/optout.