Пример #1
0
def uploadform(request):
    "view for upload form"
    if request.method == 'POST':
        new_soft = Software(date_added=datetime.now(),
                            download_count=0,
                            show=False,
                            link="default link",
                            size=20,
                            uploaded_by="backwas")  #change default link
        form = SoftwareForm(request.POST, instance=new_soft)  #request.FILES,
        if form.is_valid():
            #			handle_uploaded_file(request.FILES['file'])
            form.save()
            return render_to_response('index.html')
        return render_to_response('index.html', {
            'form': form,
        },
                                  context_instance=RequestContext(request))
        form = SoftwareForm(request.POST)
    else:
        form = SoftwareForm()
    return render_to_response('uploadform.html', {
        'form': form,
    },
                              context_instance=RequestContext(request))
Пример #2
0
def uploadform(request):
    if request.method == 'POST':
        form = SoftwareForm(request.POST)
        if form.is_valid():
            return HttpResponseRedirect('/softwares/success')
    else:
        form = SoftwareForm()
    return render_to_response('uploadform.html', {
        'form': form,
    },
                              context_instance=RequestContext(request))
Пример #3
0
def upload(request):
    new_soft = Software(date_added=datetime.now(),
                        download_count=0,
                        show=False,
                        link="default link",
                        size=20,
                        uploaded_by="backwas")  #change default link
    form = SoftwareForm(request.POST, instance=new_soft)
    if form.is_valid():
        form.save()
        return render_to_response('index.html')
    return render_to_response('index.html', {
        'form': form,
    },
                              context_instance=RequestContext(request))