views.py 971 B

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