你好像在示例中那样做:
How to check whether a user is online in django template?
但是在添加时
'userprofile.middleware.ActiveUserMiddleware',
到MIDDLEWARE_CLASSES
收到下一个错误:
Unhandled exception in thread started by <function wrapper at 0x7fcf6e0b8668>
Traceback (most recent call last):
File "/home/pavlo/.local/lib/python2.7/site-packages/django/utils/autoreload.py", line 226, in wrapper
fn(*args, **kwargs)
File "/home/pavlo/.local/lib/python2.7/site-packages/channels/management/commands/runserver.py", line 40, in inner_run
http_consumer=self.get_consumer(*args, **options),
File "/home/pavlo/.local/lib/python2.7/site-packages/channels/management/commands/runserver.py", line 136, in get_consumer
return StaticFilesConsumer()
File "/home/pavlo/.local/lib/python2.7/site-packages/channels/handler.py", line 332, in __init__
self.handler = self.handler_class()
File "/home/pavlo/.local/lib/python2.7/site-packages/channels/staticfiles.py", line 18, in __init__
super(StaticFilesHandler, self).__init__()
File "/home/pavlo/.local/lib/python2.7/site-packages/channels/handler.py", line 179, in __init__
self.load_middleware()
File "/home/pavlo/.local/lib/python2.7/site-packages/django/core/handlers/base.py", line 82, in load_middleware
mw_instance = middleware(handler)
TypeError: this constructor takes no arguments
寻求帮助。
可能有人建议如何在Django 1.10中检查在线/离线用户