python - How to change the column header of a django-tables2 table in the view.py? -


I am using django-tables2 in my Django project and I dynamically according to some column, Would like to change the database query, which is done in view.py

I know that the "verbose_name" attribute of each of the columns in each of the tables can be changed, but I have a templates variable "{{Headerxy}}" for example so that they can dynamically change.

Or is there a way to change the "verbose_name" attribute view.py?

Something like this:

  table.column ['column1']. Header = some_data   

thanks

What do you do here When starting the table class, give the name of the column as the parameter, and use __init __ within that class. For example:

Table class:

  square bittable (table. Tables): def __init __ (auto, * args, c1_name = "", ** kwargs ): # Will be called the class from where c1_name will be found. Super () .__ init __ (* args, ** kwargs) self.base_columns ['column1']. Verbose_name = c1_name class meta: model = some model area = ('column1')  

see:

  class Some views (see): def (self) (Request, 'table.html', {'context': context}): Reference = {'Table': SomTable (some modell.object.all), c1_name = 'some name' / Code> 

Comments

Popular posts from this blog

python - Overriding the save method in Django ModelForm -

html - CSS autoheight, but fit content to height of div -

qt - How to prevent QAudioInput from automatically boosting the master volume to 100%? -