i18n_patterns: Ignore a route / url


I’m new to Django and I’m implementing HTMX on my project.

There is a view that only allows POST request via this decorator for an async HTMX function to work.

from django.views.decorators.http import require_POST

However I have i18n activated and due to the i18n_patterns in my root URL I will make a GET request on top of the POST request. I have confirmed this by turning off i18n. It worked then and produced no GET request.

Can I somehow tell the i18n_patterns to ignore that route so I can have both working?

In case it is needed. The code is from the django-htmx example project :


def csrf_demo(request: HtmxHttpRequest) -> HttpResponse:
    return render(request, "csrf-demo.html")

def csrf_demo_checker(request: HtmxHttpRequest) -> HttpResponse:
    form = OddNumberForm(request.POST)
    if form.is_valid():
        number = form.cleaned_data["number"]
        number_is_odd = number % 2 == 1
        number_is_odd = False
    return render(
        {"form": form, "number_is_odd": number_is_odd},


urlpatterns = [
    path("", views.index),
    path("csrf-demo/", views.csrf_demo),
    path("csrf-demo/checker/", views.csrf_demo_checker),


urlpatterns = i18n_patterns(
    path("", include("pages.urls")),
    path("admin/", admin.site.urls),


  <form hx-post="/csrf-demo/checker/" hx-headers='{"X-CSRFToken": "{{ csrf_token }}"}' hx-target="#result">
    <label for="id_number">
    <input id="id_number" name="number" type="text" placeholder=""></input>
    <button type="submit">
      Check if odd



{% if not form.is_valid %}
  Please enter a number
{% elif number_is_odd %}
  {{ form.number.value }} is odd!
{% else %}
  {{ form.number.value }} is not odd.
{% endif %}