[Fixed]-Issue with Django form POST method

1👍

As I mentioned on your last question, since you’ve changed the signature of the form’s init method you need to pass the request both times you instantiate it. You’re only doing so when it is not POST; so, when it is a POST, Python takes the data that you passing and assigns it to the request argument, leaving the data itself blank.

form = TransactionForm(request, data=request.POST, instance=transaction)

Note it is precisely for this reason that is is a bad idea to change the signature; instead, pass request as a keyword argument and inside the method get it from kwargs.

Leave a comment