class Post(models.Model):
name = models.CharField(max_length=50, verbose_name='Song title')
genre = models.ForeignKey('Genre',verbose_name='Genre', on_delete=models.DO_NOTHING)
music_file = models.FileField(upload_to='tracks/', verbose_name='Select a music file')
author = models.ForeignKey(MyUser, on_delete=models.CASCADE, related_name='author')
liked = models.ManyToManyField(MyUser, related_name='liked', blank=True)
like_counts = models.IntegerField(default=0)
online = models.BooleanField(default=False)
counter = models.IntegerField(default=0)
date = models.DateField(auto_now_add=True)
def __str__(self):
return self.name + ' -- ' + self.author.username
class Album(models.Model):
name = models.CharField(max_length=75)
music_file = models.ManyToManyField(Post)
genre = models.ForeignKey('Genre',verbose_name='Genre', on_delete=models.DO_NOTHING)
owner = models.OneToOneField(MyUser, on_delete=models.CASCADE, default='')
def __str__(self):
return self.name