How to use autobahn.ws with django?

守給你的承諾、 提交于 2019-12-03 20:19:33

Simply add the following bit of code to the python script where you setup your websocket.

if __name__ == '__main__': #pragma nocover
    # Setup environ
    sys.path.append(os.getcwd())
    os.environ.setdefault("DJANGO_SETTINGS_MODULE", "myapp.settings")
    import django
    django.setup()

Now your code that creates a web socket can make use of django models and other features just as if it was a view.

易学教程内所有资源均来自网络或用户发布的内容,如有违反法律规定的内容欢迎反馈
该文章没有解决你所遇到的问题?点击提问,说说你的问题,让更多的人一起探讨吧!