views.py 1010 B

12345678910111213141516171819202122232425262728
  1. from django.urls import reverse_lazy
  2. import requests
  3. from django.http import HttpResponse
  4. from webservice_running.apps import api
  5. from core.settings import API_URL
  6. from webservice_running.forms import OrderRegForm, RegisterUserForm
  7. from django.shortcuts import redirect, render
  8. def order_reg(request):
  9. if request.method == 'POST':
  10. form = OrderRegForm(request.POST)
  11. if form.is_valid():
  12. data = request.POST
  13. responce = requests.post(f'{API_URL}/webservice/api/webservice/', data = data, headers=api.headers)
  14. return HttpResponse(responce.text)
  15. else:
  16. form = OrderRegForm()
  17. return render(request, 'webservice_running/order_reg.html', {'form': form})
  18. def registration(request):
  19. if request.method == 'POST':
  20. form = RegisterUserForm(request.POST)
  21. if form.is_valid():
  22. form.save()
  23. return redirect('authweb')
  24. else:
  25. form = RegisterUserForm()
  26. return render(request, 'webservice_running/registration.html', {'form': form})