django-basket-c21/README.bigfilter

54 lignes
1.6 KiB
Python

# -*- mode: python ; coding: utf-8 -*-
# Copyright (C) 2012 Cliss XXI
#
# This file is part of django-basket
#
# django-basket is free software: you can redistribute it and/or modify it
# under the terms of the GNU Affero General Public License as
# published by the Free Software Foundation, either version 3 of the
# License, or (at your option) any later version.
#
# django-basket is distributed in the hope that it will be useful, but
# WITHOUT ANY WARRANTY; without even the implied warranty of
# MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the GNU
# Affero General Public License for more details.
#
# You should have received a copy of the GNU Affero General Public License
# along with this program. If not, see <http://www.gnu.org/licenses/>.
#
# Author: Vincent Adolphe
# Exemple:
# in admin.py
from django.contrib import admin
from django import forms
import basket
from my_app import models as m_models
class MyModelBFilter(basket.forms.FormBigFilter):
filtered_qs = dict(
my_filter_name1="field__id__in",
my_filter_name2="datefield__date__gte",
my_filter_name3="datefield__date__lte",
)
my_filter_name1 = forms.ModelMultipleChoiceField(
required=False, queryset=m_models.objects.all(),
widget = forms.CheckboxSelectMultiple,
label="My 1st filter")
my_filter_name2 = forms.DateField(
required=False, widget=admin.widget.AdminDateWidget,
label="Date after the:")
my_filter_name3 = forms.DateField(
required=False, widget=admin.widget.AdminDateWidget,
label="Date before the:")
class MyAdmin(basket.MixinBigFilter, admin.ModelAdmin):
class_form_big_filter = MyModelBFilter
#