:mod:`turbo` ============ .. py:module:: turbo Subpackages ----------- .. toctree:: :titlesonly: :maxdepth: 3 templatetags/index.rst Submodules ---------- .. toctree:: :titlesonly: :maxdepth: 1 apps/index.rst classes/index.rst consumers/index.rst decorators/index.rst mixins/index.rst utils/index.rst Package Contents ---------------- Classes ~~~~~~~ .. autoapisummary:: turbo.ModelBroadcast turbo.Turbo Functions ~~~~~~~~~ .. autoapisummary:: turbo.get_channel_name turbo.register turbo.autodiscover turbo.broadcast_stream Attributes ~~~~~~~~~~ .. autoapisummary:: turbo.APPEND turbo.PREPEND turbo.REPLACE turbo.UPDATE turbo.REMOVE turbo.BEFORE turbo.AFTER turbo.default_app_config .. function:: get_channel_name(identifier) .. function:: register(*models, site=None) Register the given model(s) classes with the ModelBroadcast. This attaches the on_save and on_delete methods to the provided model signals. .. code-block:: python @turbo.register(Room) class RoomBroadcast(turbo.ModelBroadcast): def on_save(self, room, created, *args, **kwargs): pass def on_delete(self, room, *args, **kwargs): pass .. class:: ModelBroadcast(model) .. class:: Turbo A reference to a specific broadcast. Broadcast names can be provided as strings or can be generated by passing in a django instance. Eg: Turbo('broadcast_name') Turbo(django_instance) .. method:: _init_with_str(self, stream_name = '') .. method:: _init_with_model(self, stream_target) .. method:: update_stream_name(self) .. method:: render(self, template_name, context=None) Returns a TurboRender object from a django template. This rendered template can then be broadcast to subscribers with the TurboRender actions (eg: append, update, etc...) Takes a template name and context identical to Django's render() method. .. method:: render_from_string(self, rendered_template) Returns a TurboRender object from a string. .. method:: remove(self, selector=None, id=None) Send a broadcast to remove an element from a turbo frame. .. data:: APPEND :annotation: = append .. data:: PREPEND :annotation: = prepend .. data:: REPLACE :annotation: = replace .. data:: UPDATE :annotation: = update .. data:: REMOVE :annotation: = remove .. data:: BEFORE :annotation: = before .. data:: AFTER :annotation: = after .. data:: default_app_config :annotation: = turbo.apps.TurboDjangoConfig .. function:: autodiscover() Look for ModelBroadcast classes in broadcasts.py .. function:: broadcast_stream(stream_target, action, template, context, dom_target=None, css_selector=None, send_type='notify', extra_payload=None) Send a Broadcast to all Websocket Clients registered to a specific stream! Here for manual control of streams and backwards-compatibility.