1π
β
You can create your own dict for form init:
if request.method == 'POST':
if need_to_convert_post(request):
post = {
'field1': None,
'field2': None,
'field3': None,
}
post['field1'] = request.POST.get('SomeOtherField1', None)
else:
post = request.POST
form = Form1(post)
else:
form = Form1()
and detect when you need to change post:
def need_to_convert_post(request):
if 'uniqueCheckField' in request.POST:
return True
return False
π€Vital Belikov
1π
For tidyness, you could use request.POST['status'] = request.POST.pop('FinalStatus')
, otherwise itβs perfectly fine to use your approach.
π€Jesse the Game
Source:stackexchange.com