[BangPypers] How to iterate through columns in Model

Senthil Kumaran senthil at uthcode.com
Thu Jul 16 21:28:48 CEST 2015


On Thu, Jul 16, 2015 at 10:51 AM, Sunil Gupta <sunil at planmytour.in> wrote:

> for each column in Obj
>      if column.help_text != "" :
>               print "The column ", column.verbose_name, " has value ",
> column.value
>
> expected output
>
> The column Client Id has value Test_Client_Id
>


Look at the attributes / methods of Obj. Does it have something like
.values() ? Check the help of your ORM to find out.
then, it will be similar to what you have done.

for column in Obj.values():
   if column.help_text is not None:
      print column.verbose_name


What ORM are you using?

-- 
Senthil


More information about the BangPypers mailing list