How to use the djangochannelsrestframework.consumers.DjangoViewAsConsumer function in djangochannelsrestframework

To help you get started, we’ve selected a few djangochannelsrestframework examples, based on popular ways it is used in public projects.

Secure your code as it's written. Use Snyk Code to scan source code in minutes - no build needed - and fix issues immediately.

github hishnash / djangochannelsrestframework / djangochannelsrestframework / consumers.py View on Github external
wrapped_view: typing.Callable[[HttpRequest], HttpResponse],
    mapped_actions: typing.Optional[typing.Dict[str, str]] = None,
) -> Type[AsyncConsumer]:
    """
    Wrap a django View so that it will be triggered by actions over this json
     websocket consumer.
    """
    if mapped_actions is None:
        mapped_actions = {
            "create": "PUT",
            "update": "PATCH",
            "list": "GET",
            "retrieve": "GET",
        }

    class DjangoViewWrapper(DjangoViewAsConsumer):
        view = wrapped_view
        actions = mapped_actions

    return DjangoViewWrapper