Closed nerdoc closed 2 years ago
That looks like the right fix. I added it to the latest branch which is getting merged into master now. Will have a new tag with this fix in shortly.
Thanks for the comprehensive report and digging in to find the fix.
turbo-django (0.4.0) released with this fix.
I am evaluating turbo-django for a project, am struggling myself throught the tutorial and creating some of the ideas in my project.
I added a (empty) Stream class named
PrescriptionRequestStream
, and included{% turbo_subscribe 'prescriptions:PrescriptionRequestStream' %}
into my template.Now Django complains:
It's a very brilliant idea to list the available streams in the error message, cool to debug. BUT: I copy'n'pasted
medux_online.plugins.prescriptions:PrescriptionRequestStream
into the templatetag. And I get the same error for that:According to
stream_for_stream_name()
, there is a hint that it should be>>> stream_for_stream_name("app.RegularStream")
- meaning the namespace before the class is the app, and it is not a dotted path.But then the app name generation in Turbo is done wrong when apps are not in the first level of Django's directory tree.
The problem seems to be in the
autodiscover_streams()
method:app_name = broadcast_module.__package__
uses a dotted path as the app name.I replaced it with
app_name = broadcast_module.__package__.split(".")[-1]
and it worked instantly.This may not be the best approach, as it's just a first glance into the code of turbo-django - maybe you have a better idea and the bigger picture.