Tuesday, 10 September 2013

Python - setattr function without self parameter, 2 parameters instead of 3

Python - setattr function without self parameter, 2 parameters instead of 3

I have the following code where I need to use setattr to generate the
variable from the string and set it equal to amn.
for i in amenities:
if i in request.GET:
amn = request.GET.getlist(i)
propertiesList = Property.objects.filter(setattr(i+"__title__in",
amn))
It seems setattr takes 3 parameters, how can I do it with just these 2
parameters?

No comments:

Post a Comment