Handling type=month Input with DateField Causes Validation Error

I have a model with a DateField named pub_date . In the admin panel, I’ve set the widget for this field to use type=month (HTML input type) so that users can select only the year and month (e.g., YYYY-MM ).

The form renders correctly in the admin panel, but when I try to save a new record, Django throws a validation error.

The data from the type=month input doesn’t make it into cleaned_data because Django’s DateField validation fails when it receives a partial date (e.g., YYYY-MM ). As a result, I can’t access or modify the value in the clean_pub_date method or other form cleaning logic.

How can I handle type=month input in Django’s admin panel without causing validation errors?

Is there a way to intercept and modify the raw POST data before Django processes it?

You might be able to modify this in the __init__ method of the form. Alter the data to be bound before calling super on the form to bind the submitted data.

POST data wrapped in a QueryDict is passed to the init method within the args tuple.

I copied the QueryDict data using copy() and made the necessary changes. I tried to combine it with the other data in args to form a new tuple, but I encountered various errors.

I found the solution by overriding the changeform_view method in the Admin class. With this method, I was able to modify the data in request.POST and pass it to the form in the way I wanted.