Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

What's the difference with turbo-django? #4

Closed
timonweb opened this issue Feb 5, 2021 · 4 comments
Closed

What's the difference with turbo-django? #4

timonweb opened this issue Feb 5, 2021 · 4 comments

Comments

@timonweb
Copy link

timonweb commented Feb 5, 2021

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?

@danjac
Copy link
Collaborator

danjac commented Feb 5, 2021

Both packages were independently started around the same time, but do very different things.

Turbo-django is mostly concerned with adding reactivity to your models, using django-channels consumers to broadcast changes as turbo-streams: so for example when your model is updated or deleted, a turbo-stream is broadcast via websocket to your frontend. It therefore requires django-channels/ASGI and websockets to work. So for example: you have some kind of news announcement model, and you want to have a notification on the navbar every time a new instance is created. You just define a template and inherit your model from BroadcastMixin to enable this functionality.

Turbo-response is used for returning turbo frames and streams as HTTP responses from normal Django views. For example, you can return a turbo frame or stream response when a user clicks a button, or lazy load pagination results into a turbo frame. It also includes middleware for detecting if the client has requested a stream/frame and respond accordingly in your view. It does have helpers you could use with channels if you wanted, but that's not the main focus, and you don't need to install channels or ASGI to use turbo-response: you can add them iteratively to your current Django project along with the turbo/stimulus client libraries.

There's an open ticket here hotwire-django/turbo-django#19 to merge these two at some point, as they do have some pieces of common functionality, but at present they have a different scope.

@timonweb
Copy link
Author

timonweb commented Feb 5, 2021

Hi Dan,

Thanks for a quick response!

So it looks like this package covers integration with Turbo Drive and Turbo Frames (as in https://turbo.hotwire.dev/), whereas turbo-django covers integration with Turbo Streams.

Yeah, for an average folk it's a bit confusing so would be great to have them all in a single package, or at least, put a note somewhere in README what is what. Because even I, who's been following and working with turbo and turbolinks is wondering what's the difference.

And thank your for your work on this!

@danjac
Copy link
Collaborator

danjac commented Feb 5, 2021

Turbo-response also handles streams. Streams have many uses other than with websockets: for example, you can use them in form validation (where you don't want to return a full page response) and you can return multiple streams in a single HTTP response : see the example here.

@timonweb
Copy link
Author

timonweb commented Feb 5, 2021

aha, them it looks like THIS package is what most people want, but everyone stars ANOTHER package :) Thanks for the great docs, I think you got it all there.

@timonweb timonweb closed this as completed Feb 6, 2021
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

2 participants