From 82399f13912402192b9cea63b9b9e14732dc27a2 Mon Sep 17 00:00:00 2001 From: Pablo Moreno Date: Fri, 17 Jul 2026 12:04:47 +0200 Subject: [PATCH] feat: htmx setup --- config/settings/base.py | 2 + crochet/templates/crochet/base.html | 18 +++++ crochet/templates/crochet/pattern.html | 65 ++++++------------- crochet/templates/crochet/pattern_detail.html | 36 ++-------- pyproject.toml | 1 + uv.lock | 15 +++++ 6 files changed, 63 insertions(+), 74 deletions(-) create mode 100644 crochet/templates/crochet/base.html diff --git a/config/settings/base.py b/config/settings/base.py index 8e1c62a..54ec4e3 100644 --- a/config/settings/base.py +++ b/config/settings/base.py @@ -29,6 +29,7 @@ THIRD_PARTY_APPS = [ 'corsheaders', 'django_extensions', 'django_filters', + 'django_htmx', 'watchman', ] @@ -55,6 +56,7 @@ MIDDLEWARE = [ 'django.contrib.auth.middleware.AuthenticationMiddleware', 'django.contrib.messages.middleware.MessageMiddleware', 'django.middleware.clickjacking.XFrameOptionsMiddleware', + 'django_htmx.middleware.HtmxMiddleware', ] if DEBUG: diff --git a/crochet/templates/crochet/base.html b/crochet/templates/crochet/base.html new file mode 100644 index 0000000..17e4c23 --- /dev/null +++ b/crochet/templates/crochet/base.html @@ -0,0 +1,18 @@ +{% load static %} + + + + + + + {% block title %}Crochet{% endblock %} + + {% block extra_css %}{% endblock %} + + + + {% block content %}{% endblock %} + {% block extra_js %}{% endblock %} + + + diff --git a/crochet/templates/crochet/pattern.html b/crochet/templates/crochet/pattern.html index 1510339..49cd450 100644 --- a/crochet/templates/crochet/pattern.html +++ b/crochet/templates/crochet/pattern.html @@ -1,33 +1,28 @@ -{% load static i18n %} - - +{% extends 'crochet/base.html' %} +{% load static i18n django_htmx %} - - - +{% block title %}Crochet{% endblock %} + +{% block body_attrs %} hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}'{% endblock %} + +{% block extra_css %} - Crochet - - - - + {% htmx_script %} - + + +{% endblock %} + +{% block content %}

Crochet

- +