def model_form_upload(request): if request.method == 'POST': form = DocumentForm(request.POST, request.FILES) if form.is_valid(): form.save() return redirect('form_upload') else: form = DocumentForm() return render(request, 'blog/model_form_upload.html', {'form': form})
def findMissing(request): if request.method == 'POST': form = DocumentForm(request.POST, request.FILES) if form.is_valid(): form.save() result = searchImage(request.FILES['document'].name, form.cleaned_data['name']) request.session['result'] = result return HttpResponseRedirect(reverse('blog:myresults')) else: form = DocumentForm() return render(request, 'blog/findMissing.html', {'form': form})
def upload_file(request): global rate global file form = DocumentForm(request.POST, request.FILES) if form.is_valid(): rate = form.cleaned_data['description'] file = form.cleaned_data['document'].name if form.is_valid(): form.save() return HttpResponseRedirect(reverse('main_chart')) else: form = DocumentForm() return render(request, 'blog/add_data.html', {'form': form}, context_instance=RequestContext(request))
def post_new(request): if request.method == "POST": form = DocumentForm(request.POST, request.FILES) if form.is_valid(): post_new = form.save(commit=False) post_new.author = request.user post_new.save() return redirect('my-view') else: form = DocumentForm() return render(request, 'blog/post_edit.html', {'form': form})