Sometimes, you will need to get the current authenticated user in models, or other parts of your app.

To achieve this, you must create this middleware in your app(middleware.py) and add it to MIDDLEWARE_CLASSES in project settings:

‘myapp.middleware.GlobalUserMiddlware’

Use Example:

Refrence: http://simionbaws.ro/programming/python-programming/django-python-programming/django-get-current-user-globally-in-the-project/

Leave a Reply

Your email address will not be published. Required fields are marked *