GibbsConsulting / django-plotly-dash

Expose plotly dash apps as django tags
MIT License
538 stars 121 forks source link

Redirect from Dash app back to Django home page #371

Open mouhannadali opened 2 years ago

mouhannadali commented 2 years ago

I was able to redirect to a dash app from Django using the tag: ` {%load plotly_dash%}

but couldn't find a way to navigate (redirect) back to the Django home page template. any idea??

GibbsConsulting commented 2 years ago

When you register you urls, you can name each route. Insert a link back to the homepage using something like {% url "home"%} where home should be replaced by the name of the route.

See the django documentation for more info. Google will be your friend here.

mouhannadali commented 2 years ago

hi @GibbsConsulting , in Django HTML template I can add a href={% url "home"%} but I am not able to use it inside the plotly dash app I tried to do something like this

  dbc.Button(
      "Skip", id="skip-button", external_link=True, href="../../", outline=True,
  ),

it opens the home page but inside the dash app layout ...

GibbsConsulting commented 2 years ago

Ah OK, you want to be able to say to the outer page, from the inner iframe, 'please go to X'. I suspect your alternatives are (a) dont use the iframe version of the template, which does have other implications such as the lack of encapsulation, or (b) some javascript to communicate to the outer page.

The latter would be a nice feature to have in general, as would the closely related one of allowing separate dash apps on the same page to communicate with each other.

hetryn commented 2 months ago

Has anyone been able to solve this? I am unable to use the non-iframe version as i need to input some initial_arguments.