2010-07-11 72 views

回答

1

感謝彼得對他有用的例子。

def fake_requested_from_root(fn): 
    """ 
    Login decorator which when used on a view modifies the reqquest.path 
    to fool the template into thibking that the request is coming from the 
    root page 
    """ 
    def decorator(request, **kwargs): 
     request.path = reverse('home') 
     return fn(request, **kwargs) 
    return decorator