2๐
โ
I think what you want to do is define Category as a Model with a Many-to-Many relationship with Album. That way, you can do things like: Album.objects.filter(category__name='country')
or you could take an instance of Category and do category.album_set.all()
Try this above your Album model:
class Category(models.Model):
name = models.CharField(max_length=50)
desc = models.TextField()
Then add to your Album model:
category = models.ManyToManyField(Category)
๐คperfect5th
Source:stackexchange.com