Consumers

class djangochannelsrestframework.consumers.APIConsumerMetaclass(name, bases, body)[source]

Metaclass that records action methods

class djangochannelsrestframework.consumers.AsyncAPIConsumer(*args, **kwargs)[source]

Be very inspired by django rest framework ViewSets

async check_permissions(action: str, **kwargs)[source]

Check if the action should be permitted. Raises an appropriate exception if the request is not permitted.

async get_permissions(action: str, **kwargs)[source]

Instantiates and returns the list of permissions that this view requires.

async handle_action(action: str, request_id: str, **kwargs)[source]

run the action.

async handle_exception(exc: Exception, action: str, request_id)[source]

Handle any exception that occurs, by sending an appropriate message

async receive_json(content: Dict, **kwargs)[source]

Called with decoded JSON content.

class djangochannelsrestframework.consumers.DjangoViewAsConsumer(*args, **kwargs)[source]
async handle_action(action: str, request_id: str, **kwargs)[source]

run the action.

async receive_json(content: Dict, **kwargs)[source]

Called with decoded JSON content.

djangochannelsrestframework.consumers.view_as_consumer(wrapped_view: Callable[[django.http.request.HttpRequest], django.http.response.HttpResponse], mapped_actions: Optional[Dict[str, str]] = None)djangochannelsrestframework.consumers.DjangoViewAsConsumer[source]
Wrap a django View so that it will be triggered by actions over this json

websocket consumer.