On Fri, Apr 13, 2012 at 1:51 PM, Phang Mulianto <braveh...@gmail.com> wrote:
> Hi ,
>
> i already try

Randomly trying things is unlikely to fix anything.

cache_page decorates a function. Therefore, if this doesn't work:

> (r'^$',cache_page(index), { 'template_name':
> 'blog/public_list.html'},
>> 'index'),
>

then probably the error is that you have not imported your view
function. It's hard to tell, as you just say 'different errors come
out'.

> and even :
>
> (r'^$',cache_page(index()), { 'template_name': 'blog/public_list.html'},
>> 'index'),
>

This one is nonsense. Your function 'index' is to be called when it is
to be run. Here you are trying to decorate the return value of the
function, without passing it any arguments - which is probably one of
the 'different errors'.

> but different error comes out...
> i don't know whats wrong.. anyone can help point it out..
>

If you want to decorate a view in your urls.py, you must import the
view function, and then refer to the view function by name. Like in
the example I linked you to previously…

https://docs.djangoproject.com/en/1.3/topics/cache/#specifying-per-view-cache-in-the-urlconf

So if your urlconf looked like this:

urlpatterns = ('',
    (r'^foo/(\d{1,2})/$', my_view),
)

then to add the cache_page decorator to that view, you make it like this:

urlpatterns = ('',
    (r'^foo/(\d{1,2})/$', cache_page(my_view, 60 * 15)),
)

If you continue to have problems, then you will have to tell us what
those problems are. "It doesn't work", or "different errors" is not
good enough, you must tell us word-for-word what those errors are.

Cheers

Tom

-- 
You received this message because you are subscribed to the Google Groups 
"Django users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to