0

I am a bit confused. I was reading a book about Django, and I came across a parent class that is calling itself using super() method. I am used to subclasses calling parent class using super(), but not a parent class calling itself, especially using super method. see the code below:

    class OwnerMixin(object):
        def get_queryset(self):
            qs = super(OwnerMixin, self).get_queryset()
            return qs.filter(owner=self.request.user)
Svetlin Zarev
  • 14,713
  • 4
  • 53
  • 82
Peter kuria
  • 31
  • 1
  • 5
  • It's not calling itself, but it is incorrectly assuming that some ancestor class in its MRO has a `get_queryset` method. – chepner Jul 26 '21 at 17:58
  • It's possible that it is designed under the *assumption* that it will only be used in a class hierarchy where something does supply `get_queryset()`, though. – chepner Jul 26 '21 at 17:58
  • 1
    Does this answer your question? [use of python super function in django model](https://stackoverflow.com/questions/7141820/use-of-python-super-function-in-django-model) – ewramner Jul 26 '21 at 17:59

0 Answers0