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
This is django-import-export module that exports data into many formats

django-import-export This is django-import-export module which exports data into many formats, you can implement this in your admin panel. - Dehydrat

Shivam Rohilla 3 Jun 03, 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
Create a netflix-like service using Django, React.js, & More.

Create a netflix-like service using Django. Learn advanced Django techniques to achieve amazing results like never before.

Coding For Entrepreneurs 67 Dec 08, 2022
Utility for working with recurring dates in Django.

django-recurrence django-recurrence is a utility for working with recurring dates in Django. Documentation is available at https://django-recurrence.r

408 Jan 06, 2023
Get inside your stronghold and make all your Django views default login_required

Stronghold Get inside your stronghold and make all your Django views default login_required Stronghold is a very small and easy to use django app that

Mike Grouchy 384 Nov 23, 2022
Simple web site for sharing your short stories and beautiful pictures

Story Contest Simple web site for sharing your short stories and beautiful pictures.(Cloud computing first assignment) Clouds The table below shows cl

Alireza Akhoundi 5 Jan 04, 2023
A slick ORM cache with automatic granular event-driven invalidation.

Cacheops A slick app that supports automatic or manual queryset caching and automatic granular event-driven invalidation. It uses redis as backend for

Alexander Schepanovski 1.7k Jan 03, 2023
Use minify-html, the extremely fast HTML + JS + CSS minifier, with Django.

django-minify-html Use minify-html, the extremely fast HTML + JS + CSS minifier, with Django. Requirements Python 3.8 to 3.10 supported. Django 2.2 to

Adam Johnson 60 Dec 28, 2022
A drop-in replacement for django's ImageField that provides a flexible, intuitive and easily-extensible interface for quickly creating new images from the one assigned to the field.

django-versatileimagefield A drop-in replacement for django's ImageField that provides a flexible, intuitive and easily-extensible interface for creat

Jonathan Ellenberger 490 Dec 13, 2022
Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly.

Cookiecutter Django Powered by Cookiecutter, Cookiecutter Django is a framework for jumpstarting production-ready Django projects quickly. Documentati

Daniel Feldroy 10k Dec 31, 2022
A set of high-level abstractions for Django forms

django-formtools Django's "formtools" is a set of high-level abstractions for Django forms. Currently for form previews and multi-step forms. This cod

Jazzband 621 Dec 30, 2022
Djang Referral System

Djang Referral System About | Features | Technologies | Requirements | Starting | License | Author 🎯 About I created django referral system and I wan

Alex Kotov 5 Oct 25, 2022
Advanced school management system written in Django :)

Advanced school management system written in Django :) ⚙️ Config the project First you should make venv for this project. So in the main root of proje

AminAli Mazarian 72 Dec 05, 2022
🗂️ 🔍 Geospatial Data Management and Search API - Django Apps

Geospatial Data API in Django Resonant GeoData (RGD) is a series of Django applications well suited for cataloging and searching annotated geospatial

Resonant GeoData 53 Nov 01, 2022
Django friendly finite state machine support

Django friendly finite state machine support django-fsm adds simple declarative state management for django models. If you need parallel task executio

Viewflow 2.1k Dec 31, 2022
Django-shared-app-isolated-databases-example - Django - Shared App & Isolated Databases

Django - Shared App & Isolated Databases An app that demonstrates the implementa

Ajai Danial 5 Jun 27, 2022
An extremely fast JavaScript and CSS bundler and minifier

Website | Getting started | Documentation | Plugins | FAQ Why? Our current build tools for the web are 10-100x slower than they could be: The main goa

Evan Wallace 34.2k Jan 04, 2023
django-dashing is a customisable, modular dashboard application framework for Django to visualize interesting data about your project. Inspired in the dashboard framework Dashing

django-dashing django-dashing is a customisable, modular dashboard application framework for Django to visualize interesting data about your project.

talPor Solutions 703 Dec 22, 2022
Automatically reload your browser in development.

django-browser-reload Automatically reload your browser in development. Requirements Python 3.6 to 3.10 supported. Django 2.2 to 4.0 supported. Are yo

Adam Johnson 254 Jan 04, 2023
This website serves as an online database (hosted via SQLLite) for fictional businesses in the area to store contact information (name, email, phone number, etc.) for fictional customers.

Django-Online-Business-Database-Project this project is still in progress Overview of Website This website serves as an online database (hosted via SQ

1 Oct 30, 2021