4👍
✅
1👍
Yes, you are right. According to the Django docs of form and field validation it will not even go to your clean
method and already raise ValidationError
in the first step (to_python
method).
There is nothing much you can do on the form level I think. What you could do though is processing the POST
data in the view before passing it to the form. Some simple example:
post_dict = request.POST.copy() #makes a copy of request.POST so you can modify it
bill = post_dict['bill']
if '$' in bill:
bill = bill.replace('$','',1)
post_dict['bill'] = bill
# pass post_dict to your form instead of request.POST
...
Source:stackexchange.com