Django – specify which model manager Django admin should use

You can choose the manager by overriding the queryset method in your ModelAdmin subclass.

def get_queryset(self, request):
    # use our manager, rather than the default one
    qs = self.model.objects.get_queryset()

    # we need this from the superclass method
    ordering = self.ordering or () # otherwise we might try to *None, which is bad ;)
    if ordering:
        qs = qs.order_by(*ordering)
    return qs

Leave a Comment

Hata!: SQLSTATE[HY000] [1045] Access denied for user 'divattrend_liink'@'localhost' (using password: YES)