def new(request): if request.method == 'POST': form = RequestForm(request.POST) if form.is_valid(): rqst = form.save() return HttpResponseRedirect(reverse('request_index', kwargs={'request_id': rqst.id})) else: form = RequestForm() return render(request, 'add.html', {'form': form, 'cancel': reverse('home')})
def index(request, request_id): rqst = get_object_or_404(Request, id=request_id) if request.method == "POST": form = RequestForm(request.POST, instance=rqst) if form.is_valid(): form.save() #clear request rqst.clear() rqst.save() #now submit the request to the blender url = '%s?request_id=%d' % (reverse('blender_blend', kwargs={'blender_id': rqst.blender.id}), rqst.id) return HttpResponseRedirect(url) else: form = RequestForm(instance=rqst) context = {'request': rqst, 'form': form,} return render(request, 'client.html', context)