This PR is a experimental version and many test will need it, but functional filter system.
Use list_filter as list of model attributes or FormFilter objects like:
class Myclass(CRUDView):
model = Invoice
list_filter = ['invoice_number', 'sent', 'paid']
Filter method is based on forms and filter query set, so we use different approch compared with django admin
FormFilter is a special class used for filter content based on form.
from cruds_adminlte.filter import FormFilter
class LineForm(forms.Form):
line = forms.ModelMultipleChoiceField(queryset=Line.objects.all())
class LineFilter(FormFilter):
form = LineForm
class Myclass(CRUDView):
model = Invoice
list_filter = ['sent', 'paid', LineFilter]
Magic.., not, just and good example of how to do a multiple value search based en a reverse foreignkey.
FormFilter has this public method:
render(): return a form or your own html, has an instance of form in self.form_instance, and also has self.request.
get_filter(queryset): filter your content here
get_params(exclude): clean the get parameters
I hope filter functionality has few bugs but code preserve filter it's a complex task, and filter content with high grade of liberty is hard to do, so sorry if something not work.
This PR is a experimental version and many test will need it, but functional filter system.
Use list_filter as list of model attributes or FormFilter objects like:
Filter method is based on forms and filter query set, so we use different approch compared with django admin
FormFilter is a special class used for filter content based on form.
Magic.., not, just and good example of how to do a multiple value search based en a reverse foreignkey.
FormFilter has this public method:
I hope filter functionality has few bugs but code preserve filter it's a complex task, and filter content with high grade of liberty is hard to do, so sorry if something not work.