[Django]-How to get form field value before passing the form validation?

4👍

I think this is what you’re describing –

def transaction(request): 
    if request.POST.method == 'POST':
        post = request.POST.copy()
        if 'amount' in post:
            post['amount'] = post['amount'].replace(',','')
        tform = AddTransactionForm(request.user, post)
        #...

(you have to create a copy of the request.POST dictionary because it’s immutable).

Leave a comment