def registerAPI(request): if request.method == 'POST': form = APIForm(request.POST) if form.is_valid(): data = form.save() return HttpResponseRedirect('/') else: form = APIForm() return render(request, 'registerAPI.html', {'form': form})
def changeAPI(request): if request.user.is_staff: winkAPI = WinkAPI.objects.all()[0] # Get API info if request.method == 'POST': API_form = APIForm(data=request.POST, instance=winkAPI) if API_form.is_valid(): API_form.save() return HttpResponseRedirect('/') else: API_form = APIForm(instance=winkAPI); # Form for API content = { 'API_form': API_form, } return render(request, 'changeAPI.html', content) return render(request, 'changeAPI.html', content) return HttpResponse(status=401)
def changeAPI(request): if request.user.is_staff: winkAPI = WinkAPI.objects.all()[0] # Get API info if request.method == 'POST': API_form = APIForm(data=request.POST, instance=winkAPI) if API_form.is_valid(): API_form.save() return HttpResponseRedirect('/') else: API_form = APIForm(instance=winkAPI) # Form for API content = { 'API_form': API_form, } return render(request, 'changeAPI.html', content) return render(request, 'changeAPI.html', content) return HttpResponse(status=401)