我使用 Django 自定义用户模型。在管理员中一切正常 - 登录、注销等。但是当我尝试从我自己的 view.py 调用登录时:
def my_login(request, *args, **kwargs):
response = login(request, *args, **kwargs)
return response
我收到以下错误:
AssertionError at /cust/login/
sensitive_post_parameters didn't receive an HttpRequest. If you are decorating a classmethod, be sure to use @method_decorator.
Request Method: POST
Request URL: http://localhost:8000/cust/login/
Django Version: 1.6.1
Python Version: 2.7.3
Traceback:
File "virtual_env/local/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 114. response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "virtual_env/local/lib/python2.7/site-packages/django/views/generic/base.py" in view 69. return self.dispatch(request, *args, **kwargs)
File "virtual_env/local/lib/python2.7/site-packages/django/views/decorators/csrf.py" in wrapped_view 57. return view_func(*args, **kwargs)
File "virtual_env/local/lib/python2.7/site-packages/rest_framework/views.py" in dispatch 399.response = self.handle_exception(exc)
File "virtual_env/local/lib/python2.7/site-packages/rest_framework/views.py" in dispatch 396.response = handler(request, *args, **kwargs)
File "virtual_env/local/lib/python2.7/site-packages/rest_framework/decorators.py" in handler 49.return func(*args, **kwargs)
File "virtual_env/myproject/myidentity/views.py" in my_login 13.response = login(request, *args, **kwargs)
File "virtual_env/local/lib/python2.7/site-packages/django/views/decorators/debug.py"in sensitive_post_parameters_wrapper 68."sensitive_post_parameters didn't receive an HttpRequest. If you "
Exception Type: AssertionError at /cust/login/
Exception Value: sensitive_post_parameters didn't receive an HttpRequest. If you are decorating a classmethod, be sure to use @method_decorator.
Request information:
GET: No GET data
没有找到关于这个问题的太多参考,除了这个: Django AssertionError "sensitive_post_parameters didn't receive an HttpRequest" on add users in admin
谢谢