Hotwired/Turbo Django response helpers

Overview

This package provides helpers for server-side rendering of Hotwired/Turbo streams and frames.

Disclaimer: the Hotwired/Turbo client libraries are, at time of writing, still in Beta. We expect there will be breaking changes until the first stable release. This package, and the Turbo client, should therefore be used with caution in a production environment. The version used in testing is @hotwired/turbo==7.0.0-beta.4.

Requirements

This library requires Python 3.7+ and Django 3.0+.

Installation

pip install django-turbo-response

To install from Git:

git clone https://github.com/hotwire-django/django-turbo-response

cd django-turbo-response

python setup.py install

Note: This library does not include any client libraries (Turbo or Stimulus). You may wish to add these yourself using your preferred Javascript build tool, or use a CDN. Please refer to the Hotwire documentation on installing these libraries.

Full documentation on ReadTheDocs:

https://django-turbo-response.readthedocs.io/en/latest/

License

This project is covered by the MIT license.

Comments
  • XSS vulnerable

    XSS vulnerable

    The code in renderers.py uses f-strings to template HTML with HTML-escaping incoming strings. This means user content being used in a response could be reflected and rendered in the browser.

    opened by adamchainz 4
  • What's the difference with turbo-django?

    What's the difference with turbo-django?

    Hi guys,

    I'm wondering, what's the difference of this package, with another package you're working on https://github.com/hotwire-django/turbo-django? Can't django-turbo-response be merged into turbo-django?

    opened by timonweb 4
  • Inherit from TurboFormMixin in CBVs

    Inherit from TurboFormMixin in CBVs

    Fixes #8

    @danjac The TurboFormModelMixin is no longer used anywhere. Potentially worth deleting but it depends if you think people are inheriting from it directly?

    opened by davidkell 2
  • TurboFormMixin call super().form_valid()

    TurboFormMixin call super().form_valid()

    An example is below where email is not sent on form validation in PasswordResetView:

    class PasswordResetView(TurboStreamFormMixin, auth_views.PasswordResetView):
        target = "form-reset"
        template_name = "accounts/auth/password_reset.html"
    
    opened by avinashjoshi 2
  • Duplicate saves in TurboCreateView

    Duplicate saves in TurboCreateView

    After debugging, we noticed that the form is saved twice in TurboCreateView.

    Relevant source code:

    # mixins.py
    class TurboFormModelMixin(TurboFormMixin):
    
        object: Optional[Model]
    
        def form_valid(self, form: forms.Form) -> HttpResponse:
            """If the form is valid, save the associated model."""
            self.object = form.save()
            return super().form_valid(form)
    
    # views.py
    
    class TurboCreateView(TurboFormModelMixin, CreateView):
        ...
    
    

    But the Django CreateView already uses the ModelFormMixin with:

    def form_valid(self, form):
        """If the form is valid, save the associated model."""
        self.object = form.save()
        return super().form_valid(form)
    

    The result is that form.save() is called twice.

    I think the fix is:

    class TurboCreateView(TurboFormMixin, CreateView):
        ...
    ```
    
    Ditto `TurboUpdateView`. Thoughts?
    opened by davidkell 1
  • Question about the future

    Question about the future

    Hello,

    I see that you have switched from Hotwire to htmx in one of your personal projects. Does it mean you won't update djanto-turbo-response anymore ot just decided to use the other tool ?

    I know there's been a lot of noise in Basecamp etc. and I am worried about the the future of Hotwire.

    What is your opinion on that ?

    Thanks for your work on the project and all the Howtire Django stuff.

    opened by rtpm 1
  • csrf token is not rendered in TurboStream Responses

    csrf token is not rendered in TurboStream Responses

    If you render a Form containing {% csrf_token %} it is not rendered.

    This is related to this issue: https://stackoverflow.com/questions/34629261/django-render-to-string-ignores-csrf-token

    opened by JulianFeinauer 4
Releases(0.0.52)
Owner
Hotwire for Django
Support for @hotwired in Django
Hotwire for Django
Show how the redis works with Python (Django).

Redis Leaderboard Python (Django) Show how the redis works with Python (Django). Try it out deploying on Heroku (See notes: How to run on Google Cloud

Tom Xu 4 Nov 16, 2021
Mobile Detect is a lightweight Python package for detecting mobile devices (including tablets).

Django Mobile Detector Mobile Detect is a lightweight Python package for detecting mobile devices (including tablets). It uses the User-Agent string c

Botir 6 Aug 31, 2022
Strict separation of config from code.

Python Decouple: Strict separation of settings from code Decouple helps you to organize your settings so that you can change parameters without having

Henrique Bastos 2.3k Jan 04, 2023
Imparare Django ricreando un sito facsimile a quello Flask

SitoPBG-Django Imparare Django ricreando un sito facsimile a quello Flask Note di utilizzo Necessita la valorizzazione delle seguenti variabili di amb

Mario Nardi 1 Dec 08, 2021
A Django chatbot that is capable of doing math and searching Chinese poet online. Developed with django, channels, celery and redis.

Django Channels Websocket Chatbot A Django chatbot that is capable of doing math and searching Chinese poet online. Developed with django, channels, c

Yunbo Shi 8 Oct 28, 2022
Helps working with singletons - things like global settings that you want to edit from the admin site.

Django Solo +---------------------------+ | | | | | \ | Django Solo helps

Sylvain ToΓ© 726 Jan 08, 2023
Domain-driven e-commerce for Django

Domain-driven e-commerce for Django Oscar is an e-commerce framework for Django designed for building domain-driven sites. It is structured such that

Oscar 5.6k Jan 01, 2023
A Django app to initialize Sentry client for your Django applications

Dj_sentry This Django application intialize Sentry SDK to your Django application. How to install You can install this packaging by using: pip install

Gandi 1 Dec 09, 2021
Loguru is an exceeding easy way to do logging in Python

Django Easy Logging Easy Django logging with Loguru Loguru is an exceeding easy way to do logging in Python. django-easy-logging makes it exceedingly

Neutron Sync 8 Oct 17, 2022
A Django web application to receive, virus check and validate transfers of digital archival records, and allow archivists to appraise and accession those records.

Aurora Aurora is a Django web application that can receive, virus check and validate transfers of digital archival records, and allows archivists to a

Rockefeller Archive Center 20 Aug 30, 2022
Build reusable components in Django without writing a single line of Python.

Build reusable components in Django without writing a single line of Python. {% #quote %} {% quote_photo src="/project-hail-mary.jpg" %} {% #quot

Mitchel Cabuloy 277 Jan 02, 2023
Django query profiler - one profiler to rule them all. Shows queries, detects N+1 and gives recommendations on how to resolve them

Django Query Profiler This is a query profiler for Django applications, for helping developers answer the question "My Django code/page/API is slow, H

Django Query Profiler 116 Dec 15, 2022
Django React Flight Rezervation

Django Intro & Installation python -m venv venv source ./venv/Scripts/activate pip install Django pip install djangorestframework pip install python-d

HILMI SARIOGLU 2 May 26, 2022
PEP-484 stubs for Django

pep484 stubs for Django This package contains type stubs and a custom mypy plugin to provide more precise static types and type inference for Django f

TypedDjango 1.1k Dec 30, 2022
Money fields for Django forms and models.

django-money A little Django app that uses py-moneyed to add support for Money fields in your models and forms. Django versions supported: 1.11, 2.1,

1.4k Jan 06, 2023
Flashback is an awesome, retro IRC based app built using Django

Flashback Flashback is an awesome, retro IRC based app built using Django (and the Django Rest Framework) for the backend as well as React for the fro

Unloading Gnat 1 Dec 22, 2021
E-Commerce Platform

Shuup Shuup is an Open Source E-Commerce Platform based on Django and Python. https://shuup.com/ Copyright Copyright (c) 2012-2021 by Shuup Commerce I

Shuup 2k Jan 07, 2023
βœ‹ Auto logout a user after specific time in Django

django-auto-logout Auto logout a user after specific time in Django. Works with Python 🐍 β‰₯ 3.7, Django 🌐 β‰₯ 3.0. βœ”οΈ Installation pip install django-a

Georgy Bazhukov 21 Dec 26, 2022
A middleware to log the requests and responses using loguru.

Django Loguru The extension was based on another one and added some extra flavours. One of the biggest problems with the apps is the logging and that

Tiago Silva 9 Oct 11, 2022
This is raw connection between redis server and django python app

Django_Redis This repository contains the code for this blogpost. Running the Application Clone the repository git clone https://github.com/xxl4tomxu9

Tom Xu 1 Sep 15, 2022