[Django]-Modelform fails is_valid w/o setting form.errors

8👍

Your form is unbound, because you are not passing any data to it. Calling is_valid on an unbound form will always return False, with empty errors (see the form api docs).

Your view should be something like the following:

def editClip(request, clipId):
    clip = Videofiles.objects.get(filenamebase=clipId)
    if request.method == 'POST':
        # create bound form with input from request.POST
        form = VideoFilesForm(request.POST, instance=clip)
        if 'save' in request.POST:
            if form.is_valid():
            form.save()
        else:
            print form.errors
    else:
        # create unbound form to display in template
        form = VideoFilesForm(instance=clip)
            return render_to_response('legacyDB/edit_clip.html',locals())

Leave a comment