question-mark
Stuck on an issue?

Lightrun Answers was designed to reduce the constant googling that comes with debugging 3rd party libraries. It collects links to all the places you might be looking at while hunting down a tough bug.

And, if you’re still stuck at the end, we’re happy to hop on a call to see how we can help out.

Key Error [Question]

See original GitHub issue

Just starting out and can’t seem to insert dash into one of my django Applications. I followed the installation and simple usage guide.

I have done the following:

added 'django_plotly_dash.apps.DjangoPlotlyDashConfig' to INSTALLED_APPS in settings. added 'django_plotly_dash.middleware.BaseMiddleware', to MIDDLEWARE in settings

added path('django_plotly_dash/', include('django_plotly_dash.urls')), to my projects urls.py file

Successfully updated the database

created dash app nammed ‘dash_app.py’ and its located in the same folder as the projects settings.py and urls.py file.

Updated template to include {%load plotly_dash%} {%plotly_app name="SimpleExample"%}

and lastly my view.py file looks like this: `class HomePage2(ListView): model = main_kpi template_name = ‘home\home.html’ context_object_name = ‘list_of_kpis’

def get_context_data(self, **kwargs):
    # Call the base implementation first to get a context
    context = super().get_context_data(**kwargs)
    dash_context = self.request.session.get("django_plotly_dash", dict())
    dash_context['django_to_dash_context'] = "I am Dash receiving context from Django"
    self.request.session['django_plotly_dash'] = dash_context
    return context

`

When I bring up the application in debug mode I get the following error: KeyError at /home/ 'Unable to find stateless DjangoApp called simpleexample'

Is there something i’m missing? Happy to update docs with a straight forward how to guide for beginners if I can get this figured out.

Issue Analytics

  • State:closed
  • Created 5 years ago
  • Comments:9 (5 by maintainers)

github_iconTop GitHub Comments

5reactions
vantaka2commented, Jan 9, 2019

After a lot trial and error I think I found what I did wrong. in url.py I never imported my dash file:

from . import dash_app

This is even stated in the ‘Simple Useage’ The example Django application in the demo subdirectory achieves this through an import in the main urls.py file

Might be a bit easier for beginners to show the actual import? I can submit a pull request if you think that would be worthwhile.

Thanks!

1reaction
bryliecommented, May 14, 2021

I opened another pull request to clarify how to register the Plotly app with Dash in the Installation document.

Read more comments on GitHub >

github_iconTop Results From Across the Web

Python KeyError Exceptions and How to Handle Them
The Python KeyError is a type of LookupError exception and denotes that there was an issue retrieving the key you were looking for....
Read more >
I'm getting Key error in python - Stack Overflow
A KeyError generally means the key doesn't exist. So, are you sure the path key exists? From the official python docs: exception KeyError....
Read more >
Python KeyError: A Beginner's Guide % - Career Karma
A Python KeyError occurs when you attempt to access an item in a dictionary that does not exist using the indexing syntax. This...
Read more >
What is KeyError in Python? Dictionary and Handling Them
KeyError in Python is raised when you attempt to access a key that is not in a dictionary.
Read more >
keyerror in Python – How to Fix Dictionary Error
When working with dictionaries in Python, a KeyError gets raised when you try to access an item that doesn't exist in a Python...
Read more >

github_iconTop Related Medium Post

No results found

github_iconTop Related StackOverflow Question

No results found

github_iconTroubleshoot Live Code

Lightrun enables developers to add logs, metrics and snapshots to live code - no restarts or redeploys required.
Start Free

github_iconTop Related Reddit Thread

No results found

github_iconTop Related Hackernoon Post

No results found

github_iconTop Related Tweet

No results found

github_iconTop Related Dev.to Post

No results found

github_iconTop Related Hashnode Post

No results found