Exemplo n.º 1
0
def test_page(request):
    if request.method == 'POST':
        form = FileForm(request.POST, request.FILES)
        if form.is_valid():
            new_file = File(file=request.FILES['file'])
            new_file.save()

            return HttpResponseRedirect(reverse('test_page'))
    else:
        form = FileForm()

    context = {'form': form}
    return render(request, 'test_page.html', context)
Exemplo n.º 2
0
def edit_document(request, slug):
    document = Document.objects.get(slug=slug)
    context = {'slug': slug}
    if request.method == 'POST':
        form = FileForm(request.POST, request.FILES)
        context['form'] = form
        if form.is_valid():
            new_file = File(file=request.FILES['file'])
            new_file.save()

            return render(request, 'edit_document.html', context)
    else:
        form = FileForm()

    context['form'] = form
    return render(request, 'edit_document.html', context)