GibbsConsulting / django-plotly-dash

Expose plotly dash apps as django tags
MIT License
548 stars 124 forks source link

No DashApp matches the given query. #435

Open Gjergji97 opened 1 year ago

Gjergji97 commented 1 year ago

Hi everyone, I have been trying to implement the 10th demo, on my project, but I keep getting No DashAPP matches the given query error. It is quite frustrating since I have tried almost everything till now. Apparently the Queryset in

def _get_queryset(klass):

returns an empty query. Every help is very appreciated. Thanks

Request Method: GET

http://http://127.0.0.1:8000/dash_prediction/

My Urls

urlpatterns = [

              # path("", home_view.home, name="home"),
              path("", include('home.urls')),
              path("", include('upload_apks.urls')),
              path("", include('manage_mongo.urls')),
              path("", include('prediction.urls')),
              path("", include('train_system.urls')),
              path("", include('redis_flower_monitor.urls')),
              path("", include('generate_train_data.urls')),
              path("", include('preprocess_train_data.urls')),
              path("", include('prediction.urls')),
              path("", include('dash_prediction.urls')),
              path("admin/", admin.site.urls),
              path("django_plotly_dash/", include('django_plotly_dash.urls')),
              path("start_apk_processor_thread/", home_view.start_apk_processor_thread,
                   name="start_apk_processor_thread"),

          ] + static(settings.STATIC_SUFFIX, document_root=settings.STATIC_ROOT)

My dash_prediction app urls

urlpatterns = [ path('dash_prediction/', TemplateView.as_view(template_name='dashpred.html'), name="dash_prediction_start"), ] + static(settings.STATIC_SUFFIX, document_root=settings.STATIC_ROOT)

My dashpred.html which gets rendered if I delete the row where the plottly app gets inserted

{% extends 'home.html' %} {%load plotly_dash%}

{%block title%}Demo Ten - Multiple Callback Values{%endblock%}

{%block content%}

{%plotly_app slug="multiple-callback-values-1" ratio=0.9 %}

{%endblock%}

delsim commented 1 year ago

At some point in your application you should create and persist an instance of your app associated with that slug. The tag documentation is here and you might like to consider referencing the app by DjangoDash app name rather than DashApp instance if it is the same each time.

Also, see this guide on how to format issues etc so that code samples are readable.

delsim commented 1 year ago

In other words, if you use the same app instance each time the template is rendered, rather than have some sort of per-user or per-session variant, change the template tag to use

{%plotly_app name="NameUsedInDjangoDashConstructorCallForApp" ratio=0.9 %}

Also, don't forget to ensure that the file that has that constructor call is imported somewhere by Django. A common practice is to pull it into the urls.py file.