1👍
✅
The pattern for a method that operates on a QuerySet
is to use a model manager.
class CliProfileManager(models.Manager):
def get_subscribed_clients(self, shop):
return self.get_queryset().exclude(unsubscriptions__shop=shop)
class CliProfile(...):
objects = CliProfileManager()
profiles = CliProfile.objects.filter(...)
subscribed = profiles.get_subscribed_clients()
subscribed = profiles.objects.get_subscribed_clients()
Source:stackexchange.com