[Answer]-Django content type and file size restriction

1👍

You have to use form validation.

from django.forms import models as model_forms

def resview(request):
    if request.method == "POST":
        form_class = model_forms.modelform_factory(resmodel)
        form = form_class(request.POST)
        if form.is_valid():
            details = form.save()
        return HttpResponseRedirect('/profile/save/success/')
    else:
        return render_to_response('file.html')

But pay attention that this is basic form usage.

In future you should to pass form to template context and fill template with form data to display form inputs, labels and validation errors.

More documentation here Creating forms from models
and here Working with forms

Leave a comment