0.1.3
create route form fixed
This commit is contained in:
@@ -20,14 +20,25 @@ class CreateRouteForm(forms.ModelForm):
|
||||
# print('check')
|
||||
cleaned_data = super(CreateRouteForm, self).clean()
|
||||
|
||||
data = dict(self.data)
|
||||
|
||||
if 'from_place' in data and data['from_place'] not in [item[0] for item in self.fields['from_place'].choices]:
|
||||
self.cleaned_data['from_place'] = transfer_location_choices[0][0]
|
||||
if 'to_place' in data and data['to_place'] not in [item[0] for item in self.fields['to_place'].choices]:
|
||||
self.cleaned_data['to_place'] = transfer_location_choices[0][0]
|
||||
if 'cargo_type' in data and data['cargo_type'] not in [item[0] for item in self.fields['cargo_type'].choices]:
|
||||
self.cleaned_data['cargo_type'] = cargo_type_choices[0][0]
|
||||
|
||||
try:
|
||||
|
||||
if 'from_place' in self.data and self.data['from_place'] not in [item[0] for item in self.fields['from_place'].choices]:
|
||||
cleaned_data['from_place'] = self.fields['from_place'].choices[0][0]
|
||||
if 'from_place' in self.errors and self.errors['from_place'].data[0].code == 'invalid_choice':
|
||||
del self.errors['from_place']
|
||||
if 'to_place' in self.data and self.data['to_place'] not in [item[0] for item in self.fields['to_place'].choices]:
|
||||
cleaned_data['to_place'] = self.fields['to_place'].choices[0][0]
|
||||
if 'to_place' in self.errors and self.errors['to_place'].data[0].code == 'invalid_choice':
|
||||
del self.errors['to_place']
|
||||
if 'cargo_type' in self.data and self.data['cargo_type'] not in [item[0] for item in self.fields['cargo_type'].choices]:
|
||||
cleaned_data['cargo_type'] = self.fields['cargo_type'].choices[0][0]
|
||||
if 'cargo_type' in self.errors and self.errors['cargo_type'].data[0].code == 'invalid_choice':
|
||||
del self.errors['cargo_type']
|
||||
|
||||
except Exception as e:
|
||||
print(str(e))
|
||||
|
||||
# reg_user = check_authorizationBy_cleaned_data(cleaned_data)
|
||||
# # print(reg_user)
|
||||
|
||||
Reference in New Issue
Block a user