我有一个抽象类
我想要这样:
def detail(request,slug):
game=get_object_or_404(Game,slug=slug)
if game.type='1'
lol=get_object_or_404(LeagueOfLegendsGame,....)
elif game.type='2'
warcraft=get_object_or_404(WarcraftGame,...)
(我知道抽象类无法创建对象。您应该建议什么)
model.py
class Game(models.Model):
slug=models.SlugField(unique=True)...
type=models.CharField(max_length=10,null=True,blank=True)
class Meta:
abstract = True
class LeagueOfLegendsGame(Game):
fields....
class WarcraftGame(Game):
fields....