Hello
I've been happily running Django 1.1.1 for a good while. It's excellent. Being a perfectionist with a deadline, I've wanted to make use of part of someone else's app which is written against 1.2. So, no problem. I read the release notes, pulled down the beta. @login_required as a method decorator no longer works, it says, so use @method_decorator to wrap. Fine. After some fiddling I found the released beta 1 doesn't have this method, so I pulled the head from SVN, and that has it. All good. So I've updated @login_required to @method_decorator(login_required) and all of my decorated views work when they get hit directly. However, the one instance where I call a view from another view (I guess I probably shouldn't do this?) I can't get to work.
I've pasted in a simplified version of my code, before and after. I'd appreciate any suggestions. I've stripped out my fancy middleware, so there's nothing exciting going on behind the scenes.
== Django 1.1.1. Works fine:
def home(request):
if True:
return dashboard(request)
return render_to_response( 'promo/home.html', {}, context_instance=RequestContext(request))
@login_required
def dashboard(request):
return render_to_response( 'dashboard.html', {}, context_instance=RequestContext(request) )
== Django 1.2 SVN. Doesn't work:
def home(request):
if True:
return dashboard(request)
return render_to_response( 'promo/home.html', {}, context_instance=RequestContext(request))
@method_decorator(login_required)
def dashboard(request):
return render_to_response( 'dashboard.html', {}, context_instance=RequestContext(request) )
== 1.2 throws this:
c:\python26\lib\site-packages\django\core\handlers\base.py in get_response
100. response = callback(request, *callback_args, **callback_kwargs) ...
c:\my_local_path\promo\views.py in home
40. return dashboard(request) ...
c:\python26\lib\site-packages\django\utils\decorators.py in _wrapper
21. return decorator(bound_func)(*args, **kwargs) ...
TypeError: "_wrapped_view() takes at least 1 argument (0 given)"
Appreciate any pointers!
Best,
A