本文整理汇总了Python中django_filters.DateFilter方法的典型用法代码示例。如果您正苦于以下问题:Python django_filters.DateFilter方法的具体用法?Python django_filters.DateFilter怎么用?Python django_filters.DateFilter使用的例子?那么, 这里精选的方法代码示例或许可以为您提供帮助。您也可以进一步了解该方法所在类django_filters
的用法示例。
在下文中一共展示了django_filters.DateFilter方法的2个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的Python代码示例。
示例1: filter_for_lookup
# 需要导入模块: import django_filters [as 别名]
# 或者: from django_filters import DateFilter [as 别名]
def filter_for_lookup(cls, field, lookup_type):
filter_class, params = super().filter_for_lookup(field, lookup_type)
if filter_class == django_filters.ChoiceFilter:
params.setdefault('widget', ButtonSelect)
params.setdefault('empty_label', _("All"))
elif filter_class in [django_filters.DateFilter, django_filters.DateTimeFilter]:
params.setdefault('widget', AdminDateInput)
elif filter_class == django_filters.DateFromToRangeFilter:
params.setdefault('widget', DateRangePickerWidget)
elif filter_class == django_filters.BooleanFilter:
params.setdefault('widget', BooleanButtonSelect)
return filter_class, params
示例2: get_filterset_extra_class_attributes
# 需要导入模块: import django_filters [as 别名]
# 或者: from django_filters import DateFilter [as 别名]
def get_filterset_extra_class_attributes(self):
ret = dict(
datemin=DateFilter(lookup_expr='gte', label='Date minimale'),
datemax=DateFilter(lookup_expr='lte', label='Date maximale'),
menu=django_filters.ChoiceFilter(
choices=EmailTemplate.MENU_CHOICES
)
)
if self.show_caisse_filter:
ret['caisse'] = type(
'CaissesFilter',
(NoopFilter, django_filters.ModelMultipleChoiceFilter),
dict()
)(
label='Caisses',
queryset=self.caisses
)
if self.show_user_filter:
qs = User.objects.filter(groups__name='UPN')
if self.request.user.profile != 'admin':
qs = qs.filter(caisses__in=self.caisses)
ret['user'] = type(
'UserFilter',
(NoopFilter, django_filters.ModelChoiceFilter),
dict()
)(
label='Utilisateur',
queryset=qs
)
return ret