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...@gmail.com wrote:

> 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 UTC+2 carlton...@gmail.com пише:
>
>> 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 <des...@gmail.com> wrote:
>>
>>> 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 homepage %}
>>>   <div class="content">
>>>      .....
>>>   </div>
>>> {% endcacheif %}
>>>
>>>
>>> -- 
>>> You received this message because you are subscribed to the Google 
>>> Groups "Django developers (Contributions to Django itself)" group.
>>> To unsubscribe from this group and stop receiving emails from it, send 
>>> an email to django-develop...@googlegroups.com.
>>> To view this discussion on the web visit 
>>> https://groups.google.com/d/msgid/django-developers/bcf8ffee-6497-4a55-ba40-913446d15b06n%40googlegroups.com
>>>  
>>> <https://groups.google.com/d/msgid/django-developers/bcf8ffee-6497-4a55-ba40-913446d15b06n%40googlegroups.com?utm_medium=email&utm_source=footer>
>>> .
>>>
>>

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to django-developers+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-developers/476159b3-7f5f-4264-994b-1b62b8adaf8fn%40googlegroups.com.

Reply via email to