You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
Most of my custom scripts, start by logging the username and IP address like this:
username=self.request.user.usernameip_address=self.request.META.get('HTTP_X_FORWARDED_FOR') or \
self.request.META.get('REMOTE_ADDR')
self.log_info(f"Running as user {username} (IP: {ip_address})...")
But if the script is triggered by CLI, it seems to pick a random username, I don't know why. And the META dict is empty. If I add a test for if META = {} is that a reliable way to know it's run by CLI, or are there other things which could cause that?
reacted with thumbs up emoji reacted with thumbs down emoji reacted with laugh emoji reacted with hooray emoji reacted with confused emoji reacted with heart emoji reacted with rocket emoji reacted with eyes emoji
-
Most of my custom scripts, start by logging the username and IP address like this:
But if the script is triggered by CLI, it seems to pick a random username, I don't know why. And the
META
dict is empty. If I add a test forif META = {}
is that a reliable way to know it's run by CLI, or are there other things which could cause that?Beta Was this translation helpful? Give feedback.
All reactions