Using `django-partitions` starts with registering the models that you want to apply partitioning, or filtering, to. Somewhere that will get executed when the server startups up (like or a should import and use the register function:

from django.db.models import Q

from partitions.registry import register

register("", "products.Product", Q(partner__slug="partner-a"))
register("", "blog.Post", Q(tags__name__in=["partner", "widget"]))
register("", "products.Product", Q(partner__slug="partner-b"))
register("", "blog.Post", Q(tags__name__in=["partner", "foo"]))

Then to consume this data we can either use a template tag (ideal for external apps that are not under your control) or call the `chop` function with the same parameters in your ``.

First the templatetag:

{% load partitions_tags %}
{% partition posts using request.get_host %}

If you control the app, it makes the templates a bit cleaner to use the util function directly:

from products.models import Product

from partitions.utils import chop

def product_list(request):
    products = Product.objects.all()
    products = chop(products, by=request.get_host())