My Django admin form includes multiple file fields, each with specific validations (e.g., video files must be under 50 MB and in MP4 format). The issue arises when a user submits the form, and even if one validation fails, they have to re-upload all the files, which is frustrating and time-consuming. I came across client-side form validation as a possible solution. Is this the best approach, or are there better options?
Here’s an article I found on the topic: Easy client side form validations for Django: Django Parsley
Yes, client-side validation would be the way to go in this situation.
Handling the file uploads is probably going to take some work on your part. You’ll probably need to write the JavaScript yourself. Fortunately the JavaScript File API should make all the information available you need.
(You need to decide whether you want to check if the file actually contains an MP4 stream or only has an MP4 extension. Checking the contents for a proper file could be a lot more work.)
The validation logic is already in place on the backend. Could you please guide me on how to implement client-side validation in the admin interface?
Sorry, someone else would need to step in here to help with the details for that. We take the Django docs seriously when it comes to using the admin only for internal management tasks.