Question

i'm testing django-tables2-simplefilter. I need to understand better the inner workings. From the documentation, about defining filters:

" Add filtering options to SingleTableView. Define list of filters in the Table subclass (not in Table.Meta). Likely not secure."

I already have my working Table, with fields and meta to order e select columns

    class CouponTable(tables.Table):
         coupon = tables.Column(verbose_name="Coupon")
         description = tables.Column(accessor="coupon.description", verbose_name="Descrizione")
         activationDate = tables.DateColumn(verbose_name="Data di attivazione")
         useDate = tables.DateColumn(verbose_name="Data di utilizzo")
         sel =tables.CheckBoxColumn(accessor="pk", orderable=False )

         class Meta:
              model = yieldCoupons
              sequence= ("sel", "coupon", "description", "activationDate", "useDate")
              fields = ("sel", "coupon", "description", "activationDate", "useDate")

The first question is: 1. where should i define the filters?

Lookinkg at the code of django-tables2-simplefilter, i've seen both a template and a css. I suppose that i should include that template, in my template to show the available filters.

Is this correct?

Thanks in advance

No correct solution

OTHER TIPS

class CouponTable(tables.Table):

     coupon = tables.Column(verbose_name="Coupon")
     description = tables.Column(accessor="coupon.description", verbose_name="Descrizione")
     activationDate = tables.DateColumn(verbose_name="Data di attivazione")
     useDate = tables.DateColumn(verbose_name="Data di utilizzo")
     sel =tables.CheckBoxColumn(accessor="pk", orderable=False )
     filters = your_filters
     class Meta:
          model = yieldCoupons
          sequence= ("sel", "coupon", "description", "activationDate", "useDate")
          fields = ("sel", "coupon", "description", "activationDate", "useDate")

Edit: The function F can be imported as

from django_tables2_simplefilter import F
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top