python - Django Tables 2 limiting fields from form -


i trying limit fields in table. way see through persontable object field property fields = [first_name, last_name]. want request form. tried override get_queryset() method did not work passed in less data columns still there blank. there way generic view?

class person(models.model):      first_name =models.charfield(max_length=200)     last_name =models.charfield(max_length=200)      user = models.foreignkey("auth.user") dob = models.datefield()    class persontable(tables.table):      class meta:          model = person         fields = [first_name, last_name]   class personlist(singletableview):     model = person     table_class = persontable 

if runs same issue, there exclude instance variable on table class can override get_table , in view:

class personlist(singletableview):     model = person     table_class = persontable     template_name = "person.html"      def get_table(self):         table = super(personlist, self).get_table()         columns = self.request.get.getlist('column')         tuple_to_exclude = tuple(set(table.columns.names()) - set(columns))         table.exclude = tuple_to_exclude         return table 

Comments

Popular posts from this blog

sql - VB.NET Operand type clash: date is incompatible with int error -

SVG stroke-linecap doesn't work for circles in Firefox? -

python - TypeError: Scalar value for argument 'color' is not numeric in openCV -