[Python] Why do we call super().get_queryset() in Django's get_queryset method?

Discussão em 'Python' iniciado por Stack, Fevereiro 5, 2025.

  1. Stack

    Stack Membro Participativo

    I have a method in my Django project:

    def get_queryset(self):
    queryset = super(OrderListView, self).get_queryset()
    return queryset.filter(initiator=self.request.user)


    I don’t understand why we use queryset = super(OrderListView, self).get_queryset() inside get_queryset().

    What is the purpose of this line? What exactly does it do? Why do we call super() here? Why do we call the same method (get_queryset) inside itself? I've tried to understand it, but explanations so far haven't made it clear to me. I would appreciate a simple and satisfying answer.

    Continue reading...

Compartilhe esta Página