Looking at the code Carlton provided sounds like it meets what was being
requested, but it fails "There should be one-- and preferably only one
--obvious way to do it." in that it wasn't immediately obvious, but adding
the cacheif tag would lead to more than one way. Therefore I'm suggesting
that e
Hi Igor,
The sort of thing I had in mind was:
{% with cache_timeout=request.user.is_authenticated|yesno:"0,500" %}
{% cache cache_timeout sidebar %}
...
{% endcache %}
{% endwith %}
Kind Regards,
Carlton
On Wednesday, 12 October 2022 at 17:17:57 UTC+2 des...@gma
Hey Carlton,
I am not sure I got your idea.
The point of proposal is not in user.is_authenticated.
user.is_authenticated is just a boolean. Conditional caching for non logged
in user is just very simple and common use case when `cacheif` could be
used.
пʼятниця, 30 вересня 2022 р. о 09:09:53 U
Hey Igor,
I wonder if you can achieve the same varying the timeout parameter based in
user.is_authenticated?
Kind Regards,
Carlton
On Sat, 24 Sept 2022 at 15:35, Igor Margitich wrote:
> Hi django-developers,
>
> I would like to propose new template tag `cacheif`. Could be useful when
> you ne
Hi django-developers,
I would like to propose new template tag `cacheif`. Could be useful when
you need to cache part of html and it depends on some condition. Template
tag is similar to built-in `cache` tag but accepts extra boolean parameter.
See example:
{% cacheif user.is_anonymous 10 home