def __init__(self, input_formats=None, *args, **kwargs):
    super(YearMonthField, self).__init__(*args, **kwargs)
self.input_formats = input_formats

def clean(self, value):
    if value in validators.EMPTY_VALUES:
        return None
if isinstance(value, datetime.datetime):
    return format(value, '%Y-%m')
if isinstance(value, datetime.date):
    return format(value, '%Y-%m')
Django - Need datetime fields that can handle only year, or year and month values