I have a question whether the code is acceptable, or is there another possibility with a more optimal way out of this situation My one model look like that:
class ModelA(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
manga = models.ManyToManyField(Manga, through='ModelB')
def manga_list(self):
return ModelB.objects.filter(user=self.pk).all()
def manga_list_reading(self):
return ModelB.objects.filter(user=self.pk, type=utils.READING).all()
and second model look like that:
class ModelB(models.Model):
user = models.ForeignKey(ModelA, on_delete=models.CASCADE, )
manga = models.ForeignKey(Manga, on_delete=models.CASCADE)
type = models.CharField(max_length=30, choices=utils.LIST_PROFILE_CHOICES, null=False, blank=False)
so my question is about this def list return, is it some another option for do it ?