I need do modify data incoming to Form
before cleaning. I made it work, but It looks awful:
def __init__(self, *args, **kwargs):
if
I found another solution:
def clean(self, *args, **kwargs):
data = dict(self.data)
if 'content' in data:
content = data['content']
if isinstance(content, list):
content = content[0] # QueryDict wraps even single values to list
data['content'] = ' '.join(content.strip().split())
self.data = data # I do this trick becouse request.POST is immutable
return super(MyForm, self).clean(*args, **kwargs)
UPD: error fix: super(self.__class__, self)
may cause infinite recursion if I use form inheritance :).
UPD: seems still have troubles, and not work correctly.