Cache for individualt request.user???

89 views
Skip to first unread message

kase

unread,
Mar 6, 2012, 5:53:43 AM3/6/12
to django...@googlegroups.com
i don't know if the cache work for  views with the content dependent  from   user...

example.

@login_required
def webapp(request):
    grupos = Grupo.objects.filter(usuarios = request.user).order_by('grupo')
    return render_to_response('accounting/webapp.html',{'grupos':grupos},RequestContext(request))

if i turn  on the cache for view    @cache_page(60*10)

the user see your groups?  or see the groups for the firts user to generete the cache? and if this case? what can i do?
all my views dependent from  request.user =S

Nikolas Stevenson-Molnar

unread,
Apr 27, 2012, 7:06:05 PM4/27/12
to django...@googlegroups.com
I realize this post is a bit old now. But I believe you could resolve
this issue by adding @vary_on_cookie like so:

@login_required
@vary_on_cookie
def webapp(request):
...

You'll want to test it, of course, but that should create a different
cache for each user (since session info is stored in a cookie).

_Nik
> --
> You received this message because you are subscribed to the Google
> Groups "Django users" group.
> To view this discussion on the web visit
> https://groups.google.com/d/msg/django-users/-/OusOKXBfNoAJ.
> To post to this group, send email to django...@googlegroups.com.
> To unsubscribe from this group, send email to
> django-users...@googlegroups.com.
> For more options, visit this group at
> http://groups.google.com/group/django-users?hl=en.
Reply all
Reply to author
Forward
0 new messages