Is it possible to access the current User (i.e. user in the template context) from a custom template filter?
Obviously I can pass the user in as an argument, but if it’s possible to just grab the current user, that would be more convenient.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
Django filters aren’t given any special access to the context from which they are called, they’re just plain old functions.
You’ll need to pass in anything you want to use within the function.
https://docs.djangoproject.com/en/dev/howto/custom-template-tags/