Pass request.user to model Manager: How-to

The BookManager model requires a parameter for the request.user:

class BookManager(models.Manager):

    def get_queryset(self, user):

        return super().get_queryset().filter(author=user)

This prevents an AttributeError when calling the get_queryset method, as it now requires the parameter user to be passed.

The BookManager model requires a parameter for the request.user. The solution is to add the user parameter to the get_queryset method, like this:

class BookManager(models.Manager):

    def get_queryset(self, user):
        return super().get_queryset().filter(author=user)