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
Django URL Shortener is a Django app to to include URL Shortening feature in your Django Project

Django URL Shortener Django URL Shortener is a Django app to to include URL Shortening feature in your Django Project Install this package to your Dja

Rishav Sinha 4 Nov 18, 2021
django-reversion is an extension to the Django web framework that provides version control for model instances.

django-reversion django-reversion is an extension to the Django web framework that provides version control for model instances. Requirements Python 3

Dave Hall 2.8k Jan 2, 2023
Django-environ allows you to utilize 12factor inspired environment variables to configure your Django application.

Django-environ django-environ allows you to use Twelve-factor methodology to configure your Django application with environment variables. import envi

Daniele Faraglia 2.7k Jan 7, 2023
Rosetta is a Django application that eases the translation process of your Django projects

Rosetta Rosetta is a Django application that facilitates the translation process of your Django projects. Because it doesn't export any models, Rosett

Marco Bonetti 909 Dec 26, 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
Django project starter on steroids: quickly create a Django app AND generate source code for data models + REST/GraphQL APIs (the generated code is auto-linted and has 100% test coverage).

Create Django App ?? We're a Django project starter on steroids! One-line command to create a Django app with all the dependencies auto-installed AND

imagine.ai 68 Oct 19, 2022
django-quill-editor makes Quill.js easy to use on Django Forms and admin sites

django-quill-editor django-quill-editor makes Quill.js easy to use on Django Forms and admin sites No configuration required for static files! The ent

lhy 139 Dec 5, 2022
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
A handy tool for generating Django-based backend projects without coding. On the other hand, it is a code generator of the Django framework.

Django Sage Painless The django-sage-painless is a valuable package based on Django Web Framework & Django Rest Framework for high-level and rapid web

sageteam 51 Sep 15, 2022
A beginner django project and also my first Django project which involves shortening of a longer URL into a short one using a unique id.

Django-URL-Shortener A beginner django project and also my first Django project which involves shortening of a longer URL into a short one using a uni

Rohini Rao 3 Aug 8, 2021
Dockerizing Django with Postgres, Gunicorn, Nginx and Certbot. A fully Django starter project.

Dockerizing Django with Postgres, Gunicorn, Nginx and Certbot ?? Features A Django stater project with fully basic requirements for a production-ready

null 8 Jun 27, 2022
pytest-django allows you to test your Django project/applications with the pytest testing tool.

pytest-django allows you to test your Django project/applications with the pytest testing tool.

pytest-dev 1.1k Dec 14, 2022
APIs for a Chat app. Written with Django Rest framework and Django channels.

ChatAPI APIs for a Chat app. Written with Django Rest framework and Django channels. The documentation for the http end points can be found here This

Victor Aderibigbe 18 Sep 9, 2022
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
Django-MySQL extends Django's built-in MySQL and MariaDB support their specific features not available on other databases.

Django-MySQL The dolphin-pony - proof that cute + cute = double cute. Django-MySQL extends Django's built-in MySQL and MariaDB support their specific

Adam Johnson 504 Jan 4, 2023
Django-Audiofield is a simple app that allows Audio files upload, management and conversion to different audio format (mp3, wav & ogg), which also makes it easy to play audio files into your Django application.

Django-Audiofield Description: Django Audio Management Tools Maintainer: Areski Contributors: list of contributors Django-Audiofield is a simple app t

Areski Belaid 167 Nov 10, 2022
django Filer is a file management application for django that makes handling of files and images a breeze.

django Filer is a file management application for django that makes handling of files and images a breeze.

django CMS Association 1.6k Jan 6, 2023
Twitter Bootstrap for Django Form - A simple Django template tag to work with Bootstrap

Twitter Bootstrap for Django Form - A simple Django template tag to work with Bootstrap

tzangms 557 Oct 19, 2022
Blog focused on skills enhancement and knowledge sharing. Tech Stack's: Vue.js, Django and Django-Ninja

Blog focused on skills enhancement and knowledge sharing. Tech Stack's: Vue.js, Django and Django-Ninja

Wanderson Fontes 2 Sep 21, 2022