Django user request manager / current user

I created my own manager by creating a class that inherits from models.Manager. The manager simply changed the default model.objects request to add some filters. Now I want to add a filter according to the registered user. I do not want to search through the code, changing which parameters are added, is there a way to get the request object / current user without passing it to the method?

I hope this is not a stupid question, but I can just get confused ...

This is the basic setting of the Manager

class pubManager(models.Manager):

    def get_queryset(self):        
        return pubEnt.objects.filter(state='new')

    def on_site(self):
        return pubEnt.objects.filter(state='old', val=0)
+3
source share
2 answers

django request, . , , , ! request manager, , request (, , python). , user ( request.user), request!

+6

Source: https://habr.com/ru/post/1788871/


All Articles