我需要你的建议。我正在创建一个名为PlayList
where user's can addsongs
和movies
in his的模型playlist
。我添加了一个字段名称playlist_type
。它会询问用户是歌曲播放列表还是电影播放列表?如果是歌曲播放列表,那么他无法添加movies
到播放列表中。
好的。现在我应该使用 ContenType 还是应该再创建两个单独的模型PlayListSong
和PlayListMovies
. 你有什么建议?谢谢
class PlayList(TimeStampedModel):
SONG_PLAYLIST = 1
MOVIES_PLAYLIST = 2
PLAYLIST_CHOICES = (
(SONG_PLAYLIST, 'Songs'),
(MOVIES_PLAYLIST, 'Movies'),
)
name = models.CharField(_('PlayList Name'), max_length=100)
user = models.ForeignKey(User)
playlist_type = models.IntegerField(choices=PLAYLIST_CHOICES)
class PlayListContentType(TimeStampedModel):
playlist = models.ForeignKey(PlayList)
content_type = models.ForeignKey(ContentType, related_name="likes")
object_id = models.PositiveIntegerField()
content_object = generic.GenericForeignKey()