Polymorphism in Django

前端 未结 8 974
死守一世寂寞
死守一世寂寞 2021-01-07 06:11

I have the following models. How do I get access to the unicode of the inheriting tables (Team and Athete) from the Entity table? I\'m trying to display a l

8条回答
  •  灰色年华
    2021-01-07 06:58

    If I undestand correctly, you are simply asking how to call the __unicode__ method of a given object.

    Use unicode(instance) and depending on the type of entity, the appropriate implementation will be called polymorphically.

提交回复
热议问题