# Handling type=month Input with DateField Causes Validation Error

**URL:** <https://forum.djangoproject.com/t/handling-type-month-input-with-datefield-causes-validation-error/38320>\
**Category:** Forms & APIs\
**Created:** [January 28, 2025, 8:22pm UTC](https://forum.djangoproject.com/t/handling-type-month-input-with-datefield-causes-validation-error/38320 "2025-01-28T20:22:47Z")\
**Posts on this page:** 3\
**Page:** 1

<div class="post-metadata">

**Author:** ![kulac](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kulac/32/18306_2.png) [@kulac](https://forum.djangoproject.com/u/kulac)\
**Post date:** [January 28, 2025, 8:22pm UTC](https://forum.djangoproject.com/t/handling-type-month-input-with-datefield-causes-validation-error/38320/1 "2025-01-28T20:22:47Z")

</div>

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?

---

<div class="post-metadata">

**Author:** ![KenWhitesell](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kenwhitesell/32/280_2.png) [@KenWhitesell](https://forum.djangoproject.com/u/KenWhitesell)\
**Post date:** [January 28, 2025, 11:15pm UTC](https://forum.djangoproject.com/t/handling-type-month-input-with-datefield-causes-validation-error/38320/2 "2025-01-28T23:15:28Z")

</div>

> [@kulac](#):
>
> 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.

---

<div class="post-metadata">

**Author:** ![kulac](https://sea2.discourse-cdn.com/flex026/user_avatar/forum.djangoproject.com/kulac/32/18306_2.png) [@kulac](https://forum.djangoproject.com/u/kulac)\
**Post date:** [January 31, 2025, 8:52pm UTC](https://forum.djangoproject.com/t/handling-type-month-input-with-datefield-causes-validation-error/38320/3 "2025-01-31T20:52:07Z")

</div>

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.
