[Answered ]-Django Upload Images

2👍

I’m sure that your form is just invalid (for example there is no required slug provided). But you don’t handle this, redirecting to success page anyway. Also you’ve forgotten parentheses after is_valid, so it will be always True. Correct view will be something like this:

def submit_image(request):
    form = UploadImageForm(request.POST or None, request.FILES or None)
    if form.is_valid():
        form.save()
        return redirect('photos.views.upload_success')

    return render(request,'photos/upload.html', {
        'form': form
    })

Leave a comment