I noticed when trying to use urlresolvers.reverse, if you pass a decorated function, you get the following error:
Tried test in module testproj.views. Error was: 'function' object has no attribute 'method'
Here's a simple setup to reproduce the error:
urls.py:
from django.conf.urls.defaults import *
urlpatterns = patterns('',
( r'^test/$', 'testproj.views.test' ),
( r'^test/(?P<section>.+)/$', 'testproj.views.sect' ),
)
views.py:
from django.core import urlresolvers
from django.views.decorators.cache import cache_page
from django.http import HttpResponse
def test( req ):
s = urlresolvers.reverse( 'testproj.views.sect', kwargs={'section':'woot'} )
return HttpResponse( s )
@cache_page( 60 )
def sect( req, section ):
return HttpResponse( "section %s" % section )
Comment out the cache_page decorator and things work as expected...