GibbsConsulting / django-plotly-dash

Expose plotly dash apps as django tags
MIT License
539 stars 122 forks source link

InvalidConfig at `routes_pathname_prefix` needs to start with `/` - Question #433

Open Gjergji97 opened 1 year ago

Gjergji97 commented 1 year ago

I have already build a Dash App that has its callback functions and everything I need. Now I want to host that in a Django app. Ive been trying for three days now but keep getting :

routes_pathname_prefix needs to start with /

When debugging I notice my url_base_pathname starts with 'https', but I am new to this so I'm very confused.

My App

app = DjangoDash(name='SimpleExample', )

Settings PLOTLY_COMPONENTS = [ 'dash_core_components', 'dash_html_components', 'dash_table', 'dash_renderer', 'dpd_components', ] X_FRAME_OPTIONS = 'SAMEORIGIN' ASGI_APPLICATION = "core.routing.application" CHANNEL_LAYERS = { "default": { "BACKEND": "channels_redis.core.RedisChannelLayer", "CONFIG": { "hosts": [("127.0.0.1", 6379), ], }, }, }

STATICFILES_FINDERS = ( 'django.contrib.staticfiles.finders.FileSystemFinder', 'django.contrib.staticfiles.finders.AppDirectoriesFinder', 'django_plotly_dash.finders.DashAssetFinder', 'django_plotly_dash.finders.DashComponentFinder', )

INSTALLED_APPS = [ "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", "home", "generate_train_data", "preprocess_train_data", "django_plotly_dash.apps.DjangoPlotlyDashConfig", "channels", "channels_redis",

]

My HTML extension

{% extends 'home.html' %}

{% block content %} {% load plotly_dash %}

{% plotly_app name="SimpleExample"%}
<script src="https://cdn.plot.ly/plotly-latest.min.js"></script>

{{script| safe}} {% endblock content %} The urls

urlpatterns= [ path("", include('preprocess_train_data.urls')), path("", include('prediction.urls')), path("django_plotly_dash/", include('django_plotly_dash.urls')),] + static(settings.STATIC_SUFFIX, document_root=settings.STATIC_ROOT) It seems like nomatter what I do it won't work, any help is highly appreciated.

delsim commented 1 year ago

@Gjergji97 what is the purpose of the script tags (you have both html and Django template ones in your example)? What happens when you remove both of them? It would be really helpful if you could explain why either of them are needed here.

Also, your url path entries look strange (it is hard to tell as you haven't formatted your original post) - the first two could both try to match anything. You should address that as well. It is not possible to tell which of these will cause your (unnamed) template to render.