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
Chatbot for ordering and tracking a Pizza.

Pizza Chatbot To start the app, follow the below steps: Clone the repo using the below command: git clone Shreya Shah 1 Jul 15, 2021

Hello world written in Django.

Learning Django 💡 create a virtual environment create python -m venv ./venv. this virtualenv file will be excluded by .gitignore activate the virtual

Dipak giri 4 Nov 26, 2021
Source code for Django for Beginners 3.2

The official source code for https://djangoforbeginners.com/. Available as an ebook or in Paperback. If you have the 3.1 version, please refer to this

William Vincent 10 Jan 03, 2023
Djangoblog - A blogging platform built on Django and Python.

djangoblog 👨‍💻 A blogging platform built on Django and Python

Lewis Gentle 1 Jan 10, 2022
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
ProjectManagementWebsite - Project management website for CMSC495 built using the Django stack

ProjectManagementWebsite A minimal project management website for CMSC495 built

Justin 1 May 23, 2022
Django-Text-to-HTML-converter - The simple Text to HTML Converter using Django framework

Django-Text-to-HTML-converter This is the simple Text to HTML Converter using Dj

Nikit Singh Kanyal 6 Oct 09, 2022
Getdp-project - A Django-built web app that generates a personalized banner of events to come

getdp-project https://get-my-dp.herokuapp.com/ A Django-built web app that gener

CODE 4 Aug 01, 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
Adding Firebase Cloud Messaging Service into a Django Project

Adding Firebase Cloud Messaging Service into a Django Project The aim of this repository is to provide a step-by-step guide and a basic project sample

Seyyed Ali Ayati 11 Jan 03, 2023
Generate generic activity streams from the actions on your site. Users can follow any actors' activities for personalized streams.

Django Activity Stream What is Django Activity Stream? Django Activity Stream is a way of creating activities generated by the actions on your site. I

Justin Quick 2.1k Dec 29, 2022
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
The little ASGI framework that shines. 🌟

✨ The little ASGI framework that shines. ✨ Documentation: https://www.starlette.io/ Community: https://discuss.encode.io/c/starlette Starlette Starlet

Encode 7.7k Dec 31, 2022
Django-Docker - Django Installation Guide on Docker

Guía de instalación del Framework Django en Docker Introducción: Con esta guía p

Victor manuel torres 3 Dec 02, 2022
Returns unicode slugs

Python Slugify A Python slugify application that handles unicode. Overview Best attempt to create slugs from unicode strings while keeping it DRY. Not

Val Neekman (AvidCoder) 1.3k Dec 23, 2022
A simple polling app made in Django and Bootstrap

DjangoPolls A Simple Polling app made with Django Instructions Make sure you have Python installed Step 1. Open a terminal Step 2. Paste the given cod

Aditya Priyadarshi 1 Nov 10, 2021
Redia Cache implementation in django.

django-redis Recipe APP Simple Recipe app which shows different kinds off recipe to the user. Why Cache ? Accessing data from cache is much faster tha

Avinash Alanjkar 1 Sep 21, 2022
A small and lightweight imageboard written with Django

Yuu A small and lightweight imageboard written with Django. What are the requirements? Python 3.7.x PostgreSQL 14.x Redis 5.x FFmpeg 4.x Why? I don't

mint.lgbt 1 Oct 30, 2021
Django Persistent Filters is a Python package which provide a django middleware that take care to persist the querystring in the browser cookies.

Django Persistent Filters Django Persistent Filters is a Python package which provide a django middleware that take care to persist the querystring in

Lorenzo Prodon 2 Aug 05, 2022
A multiprocessing distributed task queue for Django

A multiprocessing distributed task queue for Django Features Multiprocessing worker pool Asynchronous tasks Scheduled, cron and repeated tasks Signed

Ilan Steemers 1.7k Jan 03, 2023