0

I want to validate my form but it uploads everytime the whole file before I get the feedback from Django which field is correct or incorrect.

Can I prevent the upload or validate it one some other ways like on the front-end. That I upload first if the form if it's correct.

Any idea?

Thanks

2
  • Why not just use frontend javascript form validation? Commented May 22, 2013 at 15:30
  • 2
    There was this stackoverflow post a while ago which talks about django javascript form validation. stackoverflow.com/questions/2318989/… At the end of the day you are going to have to do validation in JS first then do the post upon sucess. Commented May 22, 2013 at 15:30

1 Answer 1

1

The file uploads because when you submit the form, the request sent to the server includes the file.

One way you may approach this if you need to validate other fields first is maybe use some Ajax or as you suggest, front-validation with javascript. But remember, front-end validation is never enough. You can have front-end validation for performance purposes and client satisfaction but always perform a full server side validation.

This link may help you with what you want.

Hope this helps!

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.