I am trying to use a custom login url in specific view
@login_required(login_url='/account/login/')
class home(APIView):
renderer_classes = (TemplateHTMLRenderer,)
def get(self, request, format=None):
template = get_template(template_name='myapp/template.html')
return Response({}, template_name=template.template.name)
but the traceback shows
File "django/core/handlers/base.py", line 132, in get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "django/contrib/auth/decorators.py", line 22, in _wrapped_view
return view_func(request, *args, **kwargs)
TypeError: __init__() takes exactly 1 argument (2 given)
Is it possible to use custom login_required in class-based view?
thank you!
See Question&Answers more detail:
os 与恶龙缠斗过久,自身亦成为恶龙;凝视深渊过久,深渊将回以凝视…