.. _devops_click_to_edit: ========================================================================================= HTMX with Django **Example 1 Click to Edit** ========================================================================================= - http://127.0.0.1:8000/click_to_edit/init/ - https://gitlab.com/gdevops/django_htmx_examples - https://htmx.org/examples/click-to-edit/ - :ref:`hx_get` - :ref:`hx_target` - :ref:`hx_swap` :Source: - https://chriswedgwood.com/blog/htmx-examples-using-django-click-to-edit/ HTMX click-editing ===================== - https://htmx.org/examples/click-to-edit/ The click to edit pattern provides a way to offer inline editing of all or part of a record without a page refresh. This pattern starts with a UI that shows the details of a contact. The div has a button that will get the editing UI for the contact from /contacts/1/edit .. code-block:: html :linenos:
: Joe
: Blow
: joe@blow.com
This returns a form that can be used to edit the contact .. code-block:: html
**The form issues a PUT back to /contacts/1, following the usual REST-ful pattern**. Django HTMX Click To Edit ============================== - https://gitlab.com/gdevops/django_htmx_examples/-/tree/main/django_htmx_examples/click_to_edit The click to edit pattern provides a way to offer inline editing of all or part of a record without a page refresh. - http://127.0.0.1:8000/click_to_edit/init/ .. figure:: click_edit_init.png :align: center click_to_edit/templates/click_to_edit/initial_state.html --------------------------------------------------------- - https://gitlab.com/gdevops/django_htmx_examples/-/raw/main/django_htmx_examples/click_to_edit/templates/click_to_edit/initial_state.html .. code-block:: django :linenos: {% extends "base.html" %} {% block content %}
{% if contact %}

Click To Update Person

HTMX example here

First Name
{{contact.first_name}}
Last Name
{{contact.last_name}}
Email address
{{contact.email_address}}
{% else %}

You dont have a Contact , please add one in the admin!

{% endif %}
{% endblock content %}