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
Automated image processing for Django. Currently v4.0

ImageKit is a Django app for processing images. Need a thumbnail? A black-and-white version of a user-uploaded image? ImageKit will make them for you.

Matthew Dapena-Tretter 2.1k Jan 04, 2023
A Redis cache backend for django

Redis Django Cache Backend A Redis cache backend for Django Docs can be found at http://django-redis-cache.readthedocs.org/en/latest/. Changelog 3.0.0

Sean Bleier 1k Dec 15, 2022
Sampling profiler for Python programs

py-spy: Sampling profiler for Python programs py-spy is a sampling profiler for Python programs. It lets you visualize what your Python program is spe

Ben Frederickson 9.5k Jan 01, 2023
Serve files with Django.

django-downloadview django-downloadview makes it easy to serve files with Django: you manage files with Django (permissions, filters, generation, ...)

Jazzband 328 Dec 07, 2022
Store events and publish to Kafka

Create an event from Django ORM object model, store the event into the database and also publish it into Kafka cluster.

Diag 6 Nov 30, 2022
Django And React Notes App

Django & React Notes App Cloning the repository -- Clone the repository using the command below : git clone https://github.com/divanov11/Django-React

Dennis Ivy 136 Dec 27, 2022
An automatic django's update checker and MS teams notifier

Django Update Checker This is small script for checking any new updates/bugfixes/security fixes released in django News & Events and sending correspon

prinzpiuz 4 Sep 26, 2022
DCM is a set of tools that helps you to keep your data in your Django Models consistent.

Django Consistency Model DCM is a set of tools that helps you to keep your data in your Django Models consistent. Motivation You have a lot of legacy

Occipital 59 Dec 21, 2022
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 07, 2023
An URL Shortener with Basic Features.

Simple Url Shortener What is that? Yet another url shortener built with Django framework. Preview HOW TO RUN? 1. Virtual Environment First create a vi

Ethem Turgut 6 Jan 25, 2022
Bleach is an allowed-list-based HTML sanitizing library that escapes or strips markup and attributes

Bleach Bleach is an allowed-list-based HTML sanitizing library that escapes or strips markup and attributes. Bleach can also linkify text safely, appl

Mozilla 2.5k Dec 29, 2022
A feature flipper for Django

README Django Waffle is (yet another) feature flipper for Django. You can define the conditions for which a flag should be active, and use it in a num

950 Dec 26, 2022
Django channels basic chat

Django channels basic chat

Dennis Ivy 41 Dec 24, 2022
Актуальный сборник шаблонов для создания проектов и приложений на Django

О чем этот проект Этот репозиторий с шаблонами для быстрого создания Django проекта. В шаблоне проекта настроены следующий технологий: Django gunicorn

Denis Kustov 16 Oct 20, 2022
Easy thumbnails for Django

Easy Thumbnails A powerful, yet easy to implement thumbnailing application for Django 1.11+ Below is a quick summary of usage. For more comprehensive

Chris Beaven 1.3k Dec 30, 2022
Django admin CKEditor integration.

Django CKEditor NOTICE: django-ckeditor 5 has backward incompatible code moves against 4.5.1. File upload support has been moved to ckeditor_uploader.

2.2k Jan 02, 2023
A web app which allows user to query the weather info of any place in the world

weather-app This is a web app which allows user to get the weather info of any place in the world as soon as possible. It makes use of OpenWeatherMap

Oladipo Adesiyan 3 Sep 20, 2021
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
Indonesia's negative news detection using gaussian naive bayes with Django+Scikir Learn

Introduction Indonesia's negative news detection using gaussian naive bayes build with Django and Scikit Learn. There is also any features, are: Input

Harifzi Ham 1 Dec 30, 2021
Django Fett is an incomplete code generator used on several projects

Django Fett Django Fett is an incomplete code generator used on several projects. This is an attempt to clean it up and make it public for consumption

Jeff Triplett 6 Dec 31, 2021