refactor: move some fields and widgets around

This commit is contained in:
Herculino Trotta
2024-10-10 22:37:10 -03:00
parent d2cd115751
commit 5b66ac7fac
8 changed files with 110 additions and 69 deletions
+16
View File
@@ -0,0 +1,16 @@
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