Is there a different widget or argument that will allow django to only show/take the year and month input instead of year, month and day?
Currently using SelectDateWidget.
Is there a different widget or argument that will allow django to only show/take the year and month input instead of year, month and day?
Currently using SelectDateWidget.
I came across the same problem today and solved it by removing the day field via a css property and setting 1 as value for the day on clean up.
I used a ModelForm with an UpdateView and therefore had initial data in my fields which made life a bit simpler because I always had a valid value for the day of my_date_field.
A Python 3 widget sample here https://djangosnippets.org/snippets/10522/.
Example usage :
There's a snippet here, which sets the day to
1
(presuming you've got aDateField
that this value will end up in, you'll need to get some kind of day).The code is like this (just in case Django snippets disappears):