I have written a custom template tag which returns a number of users in the chat.
{% chat_online chat_channel %}
However, token seems to receive the value as chat_channel instead of the value of that variable.
What’s the matter?
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.
Remember that template tags definitions (
{% ... %})in your HTML are just pieces text being parsed by django’s template engine, so you need to tell django to actually lookup the variable in the context being rendered with the namechat_channel. This example from the docs is quite clear:where
template.Variable(date_to_be_formatted)is creating a template variable from the raw value passed to the template tag (blog_entry.date_updatedin the example) andself.date_to_be_formatted.resolve(context)is finding the actual value of that variable in the template by resolving it against the context.