当我尝试登录我的控制面板时,Django 1.10会出现错误。
Traceback(最近的调用):
File "/Users/guest/epifiction/lib/python2.7/site-packages/django/core/handlers/exception.py", line 39, in inner
response = get_response(request)
File "/Users/guest/epifiction/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
response = self.process_exception_by_middleware(e, request)
File "/Users/guest/epifiction/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
response = wrapped_callback(request, *callback_args, **callback_kwargs)
File "/Users/guest/epifiction/lib/python2.7/site-packages/django/views/decorators/cache.py", line 58, in _wrapped_view_func
add_never_cache_headers(response)
File "/Users/guest/epifiction/lib/python2.7/site-packages/django/utils/cache.py", line 230, in add_never_cache_headers
patch_response_headers(response, cache_timeout=-1)
File "/Users/guest/epifiction/lib/python2.7/site-packages/django/utils/cache.py", line 219, in patch_response_headers
if not response.has_header('Last-Modified'):
属性错误:'NoneType'对象没有属性'has_header'
以下是视图代码
class AuthorLoginView(bracesviews.AnonymousRequiredMixin,authviews.LoginView):
form_class = forms.AuthorLoginForm
template_name = 'landing_page/demo.html'
def form_valid(self, form):
username = form.cleaned_data.get('username')
userId = User.objects.get(username=username).id
try:
profile_obj = UserProfile.objects.get(user_id=userId)
except UserProfile.DoesNotExist:
return super(AuthorLoginView, self).get(self)
else:
if profile_obj.role_id == 3:
redirect = super(AuthorLoginView, self).form_valid(form)
remember_me = form.cleaned_data.get('remember_me')
if remember_me is True:
ONE_MONTH = 30 * 24 * 60 * 60
expiry = getattr(settings, "KEEP_LOGGED_DURATION", ONE_MONTH)
self.request.session.set_expiry(expiry)
return redirect