hotwire-django / turbo-django

Unmaintained // An early stage integration of Hotwire Turbo with Django
https://discuss.hotwire.dev/t/django-backend-support-for-hotwire/1570/
Other
385 stars 20 forks source link

A few small improvements #1

Closed C4ptainCrunch closed 2 years ago

C4ptainCrunch commented 3 years ago

Hi 👋

First of all, thank you @davish for sharing your code 🤗

I made a bunch of small modifications bundled in a single PR (sorry if it's messy).

I wrote a helper function: render_turbo(). That can be used when answering a form submit. If the request comes from trubo, it sends a turbo frame with the correct headers. Otherwise, it it comes from a plain request, it sends a 303 redirect

I also ensured that the demo is still working even when the JS is deactivated by including the form directly on the detail view but also in the /send view.

And some small details: