create route form fixed
This commit is contained in:
SDE
2023-07-31 17:56:54 +03:00
parent 70ff3841f6
commit b480f8a239
4 changed files with 46 additions and 41 deletions

View File

@@ -1,3 +1,5 @@
import json
from django.shortcuts import render
from uuid import uuid1
@@ -25,8 +27,12 @@ def new_route_view_ajax(request):
}
try:
data = request.POST
errors_off = True
data = request.POST
if not data and request.body:
data = json.loads(request.body)
# show_errors = False
if 'type_transport' in data:
@@ -45,14 +51,6 @@ def new_route_view_ajax(request):
('letter', _('Письмо\Документ'))
)
# form.fields['from_place'].choices = transfer_location_choices
# form.fields['to_place'].choices = transfer_location_choices
# form.fields['cargo_type'].choices = cargo_type_choices
#
# form = CreateRouteForm(data)
#
# if not form.is_valid():
# pass
else:
transfer_location_choices = (
@@ -77,27 +75,18 @@ def new_route_view_ajax(request):
form = CreateRouteForm(data)
if not form.is_valid():
pass
Dict = {
'form': form
'form': form,
'errors_off': errors_off
}
# print(form)
except Exception as e:
form.errors.append({'__all__': f'Ошибка: {str(e)}'})
# form.errors.append({'__all__': f'Ошибка: {str(e)}'})
print(str(e))
html = render_to_string('blocks/profile/b_new_route.html', Dict, request=request)
return JsonResponse({'html': html}, status=200)