Polymorphism in Django

前端 未结 8 905
死守一世寂寞
死守一世寂寞 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 07:09

    Loop over all the entities... if entity.class == 'Athlete' and entity.firstname and entity.lastname: blah

    Hope this helps.

    Edit: hmmm looks like I forgot about actually getting the combined list of both entities. Not sure I know of a slick way to do that.

提交回复
热议问题