1
Good morning, you guys.
I have a small application made entirely in Django Admin and I need to get the user logged in to make a specific query listing registered customers and and other models by this specific user/company so as to separate the application by group of users.
How can I do this with Django Admin? Because from what I read around the request
and the instance
only work in the views and how I am using only Django Admin as CRUD do not use views.
I tried to put the request inside the models.Manager
and I get an exception:
class ClienteManager(models.Manager):
def get_queryset(self, request):
return super(ClienteManager, self).get_queryset().filter(cliente=True).filter(escritorio=request.user.username)
TypeError at /admin/cadastro/cliente/
get_queryset() missing 1 required positional argument: 'request'