首页
学习
活动
专区
工具
TVP
发布
社区首页 >问答首页 >get_object_or_404继承类

get_object_or_404继承类
EN

Stack Overflow用户
提问于 2019-07-17 01:52:49
回答 1查看 54关注 0票数 0

我有一个抽象类Type,它有3个继承类Type1 Type2 Type3,这3个类的属性有70%是相同的。

我想要这样;

代码语言:javascript
复制
Tip=get_object_or_404(Type,tournament__slug=tournamentslug,slug=slug,game__slug=gameslug,) 

但是,类型是抽象类,我无法获取对象或筛选器

views.py (现在)

代码语言:javascript
复制
def game_detail(request,tournamentslug,slug,gameslug):
        tip1=get_object_or_404(Type1, tournament__slug=tournamentslug,slug=slug,game__slug=gameslug,)
        tip2=get_object_or_404(Type2,tournament__slug=tournamentslug,slug=slug,game__slug=gameslug,)
        tip3=get_object_or_404(Type3,tournament__slug=tournamentslug,slug=slug,game__slug=gameslug,)
EN
页面原文内容由Stack Overflow提供。腾讯云小微IT领域专用引擎提供翻译支持
原文链接:

https://stackoverflow.com/questions/57062945

复制
相关文章

相似问题

领券
问题归档专栏文章快讯文章归档关键词归档开发者手册归档开发者手册 Section 归档