class Article(models.Model):
def user_may_see_full_version(self, user):
# do something very sophisticated with the user
return [True/False whatever]
now i want to create a template like this:
{% for article in articles %}
{% if article.user_may_see_full_version request.user %}{{ article }}{% else %}{{article.title }}{% endif %}
{% endfor %}
but this doesn’t work because I can’t pass the argument to the method…
Is there any nice way to solve this problem?
There’s no way to pass an argument to a method directly from a template. A template filter is the best way to go:
The filter is implemented like this: