dom_id¶
dom_id is a helper method that returns a unique DOM ID based on the object’s class name and ID
{% load turbo_helper %}
{% dom_id instance %} -> task_1
{% dom_id instance 'detail' %} -> detail_task_1
{% dom_id Task %} -> new_task
dom_idfirst argument can be string, instance or Model classdom_idsecond argument is optional string that will be used asprefix.The
dom_idcan help make the id generation behavior consistent across the project, and save our time to update it inturbo-streamorturbo-frameelement.You can also use it in your Django view code.
Use in Django view
from turbo_helper import dom_id
target = dom_id(instance, "detail_container")