根据所选类型显示管理面板中的条目

时间:2019-03-06 07:22:32

标签: python django postgresql

在管理面板中创建专辑时,您要求music_track应该仅显示类型为track的标题

class Title(models.Model):
    type = models.ForeignKey(Asset_Type,on_delete=models.CASCADE,null=True)
    owner = models.ForeignKey(Partner, null=True, blank=True)
    genre = models.ForeignKey(Genres_List, null=True)

    def __str__(self):
        return "%s | %s" % (self.display_name, self.code)     

class Album(models.Model):
    album_name = models.CharField( max_length = 150, blank = False )
    titles = models.ManyToManyField( Title )
    genre = models.ForeignKey(Genres_List, null=True)
    added_on = models.DateTimeField( auto_now_add = True  )
    release_date = models.DateField(default=date.today  )

    def __str__ (self):
        return "%s" % (self.album_name)

0 个答案:

没有答案