I have this models:
from django.db import models
class Item(models.Model):
# ...
def __str__(self):
return 'item'
class SubItemA(Item):
# ...
def __str__(self):
return 'subitem_a'
class SubItemB(Item):
# ...
def __str__(self):
return 'subitem_b'
And I want to call the __str__ method from each Item in Item.object.all() and return each subclass implementation, but it only return the superclass implementation.
Example:
for item in Item.object.all():
print(item.__str__())
On my database I have two SubItemA and two SubItemB. Than it returns:
item
item
item
item
I would like to have some thing like this:
subitem_a
subitem_a
subitem_b
subitem_b
I am lost here.