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

android - Why am I getting the message 'Youractivity.java is not an activity subclass or alias' -

python - How do I create a list index that loops through integers in another list -

c# - “System.Security.Cryptography.CryptographicException: Keyset does not exist” when reading private key from remote machine -