我正在学习如何使用带有django的websockets,我正在使用django-websocket,这里是他们建议如何设置它的快速链接https://django-websocket-redis.readthedocs.io/en/latest/api.html#use-redispublisher-from-inside-django-views
我已经设置了redis,它工作正常,我也有这个视图发送请求
from django.views.generic.base import View
from ws4redis.publisher import RedisPublisher
class RenderView(View):
facility = 'render-view'
audience = {'broadcast': True}
def __init__(self, *args, **kwargs):
super(RenderView, self).init(*args, **kwargs)
self.redis_publisher = RedisPublisher(facility=self.facility, **self.audience)
def get(self, request, message):
self.redis_publisher.publish_message(message)
我用
来称呼它...
message = "Percentage {0}% \t {1}/{2} \t {3}".format(percentage, counter, (width * height), delta)
print message
socket = RenderView()
socket.get(request, message)
因此错误而被困在这里
socket = RenderView()
File "/home/samuel/Documents/code/revamp/gallery/socket.py", line 9, in __init__
super(RenderView, self).init(*args, **kwargs)
AttributeError: 'super' object has no attribute 'init'
[19/Aug/2017 21:14:48] "POST /render-part HTTP/1.1" 500 18828
答案 0 :(得分:2)
检查您的班级RenderView()
超类实例化应该是:
super(RenderView, self).__init__(*args, **kwargs)