0.1.18
edit_route fixed
This commit is contained in:
@@ -5,8 +5,9 @@ from django.urls import path
|
||||
from .js_views import *
|
||||
|
||||
urlpatterns = [
|
||||
path('change_route/<int:route_id>/', create_or_change_route_ajax, name='change_route_ajax'),
|
||||
path('create_or_change_route/', create_or_change_route_ajax, name='create_or_change_route_ajax'),
|
||||
path('create_or_change_route/<int:route_id>/', create_or_change_route_ajax, name='change_route_ajax'),
|
||||
|
||||
path('edit_route/', edit_route_ajax, name='edit_route_ajax'),
|
||||
|
||||
path('get_routes/', get_routes_ajax, name='get_routes_ajax'),
|
||||
|
||||
@@ -182,6 +182,8 @@ def create_or_change_route_ajax(request, route_id):
|
||||
if request.method != 'POST':
|
||||
raise Http404
|
||||
|
||||
Dict = {}
|
||||
|
||||
try:
|
||||
|
||||
data = request.POST
|
||||
@@ -192,12 +194,14 @@ def create_or_change_route_ajax(request, route_id):
|
||||
|
||||
if route:
|
||||
form = RouteForm(data, instance=route)
|
||||
Dict.update({'route': route})
|
||||
else:
|
||||
form = RouteForm(data)
|
||||
|
||||
if not form.is_valid():
|
||||
form.initial = form.cleaned_data
|
||||
Dict = {'form': form}
|
||||
Dict.update({'form': form})
|
||||
|
||||
html = render_to_string('blocks/profile/b_new_route.html', Dict, request=request)
|
||||
return JsonResponse({'html': html}, status=400)
|
||||
|
||||
@@ -209,7 +213,7 @@ def create_or_change_route_ajax(request, route_id):
|
||||
|
||||
if 'errors' in routes_Dict:
|
||||
form.errors.update(routes_Dict['errors'])
|
||||
Dict = {'form': form}
|
||||
Dict.update({'form': form})
|
||||
html = render_to_string('blocks/profile/b_new_route.html', Dict, request=request)
|
||||
return JsonResponse({'html': html}, status=400)
|
||||
|
||||
@@ -228,6 +232,7 @@ def create_or_change_route_ajax(request, route_id):
|
||||
'all__': f'ошибка в запросе = {str(e)}'
|
||||
}
|
||||
}
|
||||
Dict = {'form': errors_Dict}
|
||||
# Dict = {'form': errors_Dict}
|
||||
Dict.update({'form': errors_Dict})
|
||||
html = render_to_string('blocks/profile/b_new_route.html', Dict, request=request)
|
||||
return JsonResponse({'html': html}, status=400)
|
||||
Reference in New Issue
Block a user