Dynamic variable name in python

Posted by PhilGo20 on Stack Overflow See other posts from Stack Overflow or by PhilGo20
Published on 2010-04-01T22:45:03Z Indexed on 2010/04/01 22:53 UTC
Read the original article Hit count: 260

Filed under:
|

I'd like to call a query with a field name filter that I wont know before run time... Not sure how to construct the variable name ...Or maybe I am tired.

field_name = funct()
locations = Locations.objects.filter(field_name__lte=arg1)

where if funct() returns name would equal to

locations = Locations.objects.filter(name__lte=arg1)

Not sure how to do that ...

© Stack Overflow or respective owner

Related posts about python

Related posts about django