pandas - How to pass a list variable which contains column names of particular table to django model values() in Python? -


consider list below : listofcol = ['col1','col2','col3'] django model example: model.tablename.objects.values(listofcol).filter()

i fetch list of columns variable listofcol , tried mentioned in django model example , getting error message 'list' object has no attribute 'split'. in brief, table contains 50+ columns. selected columns stored in listofcol variable(columns changes periodically) need fetch through django model. there way fetch so..?

thanks in advance..!

from documentation assume need unpack list, this:

model.tablename.objects.values(*listofcol).filter() 

just assumption, please tell if works :)


Comments

Popular posts from this blog

Is there a better way to structure post methods in Class Based Views -

performance - Why is XCHG reg, reg a 3 micro-op instruction on modern Intel architectures? -

jquery - Responsive Navbar with Sub Navbar -