mirror of
https://github.com/eitchtee/WYGIWYH.git
synced 2026-03-17 23:13:57 +01:00
17 lines
377 B
Python
17 lines
377 B
Python
from datetime import datetime, date
|
|
|
|
from django import forms
|
|
|
|
|
|
class MonthYearWidget(forms.DateInput):
|
|
"""
|
|
Custom widget to display a month-year picker.
|
|
"""
|
|
|
|
input_type = "month" # Set the input type to 'month'
|
|
|
|
def format_value(self, value):
|
|
if isinstance(value, (datetime, date)):
|
|
return value.strftime("%Y-%m")
|
|
return value
|