Reputation: 15831
Hy,
Model Item Model Image Model User
Image and User are extending Item. Item extends polymodel.PolyModel.
Now I have a Model named List. Each Item has a list. Then I query all the Items for that list and I get an array of Items. Now I want to loop each object and add a property named 'type' and set it's type(Image|User).
Can somebody help me out?
Upvotes: 0
Views: 119
Reputation: 1391
You don't need to do that. The following should get you the class type for each object:
for object in object_list:
model_name = object.class_name()
Upvotes: 1