I have a library (django-piston) which is expecting some parameters of the class as class properties. I would like to define this value dynamically in a method. So I wanted to do something like:
class MyHandler(BaseHandler):
@property
def fields(self):
fields = self.model._meta.fields + self.model._meta.virtual_fields
# Do something more with fields
return fields
But it fails with:
'property' object is not iterable
So I wanted to do something like:
class iterable_property(property):
def __iter__(self):
# What here?
But I got stuck here. How could I get a property which can also be iterated over?