Я хочу обрабатывать представление POST
в Processing
, когда я набираю next/
URL прямо в строке браузера, есть подсказка? Включаю репозиторий на всякий случай: https://github.com/ivanperezdesigner/Hypercar спасибо за вашу помощь
файл views.py
class Processing(View):
def get(self, request, *args, **kwargs):
context = {'service_line': service_line}
return render(request, 'tickets/processing.html', context)
def post(self, request, *args, **kwargs):
if len(service_line['change_oil']) > 0:
service_line['change_oil'].pop(0)
elif len(service_line['inflate_tires']) > 0:
service_line['inflate_tires'].pop(0)
elif len(service_line['diagnostic']) > 0:
service_line['diagnostic'].pop(0)
return redirect('/next')
class Next(View):
def get(self, request, *args, **kwargs):
x = 0
if len(service_line['change_oil']) > 0:
x = service_line['change_oil'][0]
elif len(service_line['inflate_tires']) > 0:
x = service_line['inflate_tires'][0]
elif len(service_line['diagnostic']) > 0:
x = service_line['diagnostic'][0]
context = {'next': x}
return render(request, 'tickets/next.html', context)
файл urls.py
from django.urls import path
from tickets.views import WelcomeView, MenuView, Service, Processing, Next
from django.views.generic import RedirectView
urlpatterns = [
path('welcome/', WelcomeView.as_view()),
path('menu/', MenuView.as_view()),
path('get_ticket/<str:service>', Service.as_view()),
path('processing/', Processing.as_view()),
path('next/', Next.as_view()),
]