-
Notifications
You must be signed in to change notification settings - Fork 8
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
How do I register my dashboard class ? #8
Comments
Hi Mike, Thanks for getting in touch. Basically all you need to do to register your dashboard is add
to to bottom of your dashboards.py file. Where You need to do this for every dashboard you create. So if you had 2 dashboards,
Your final dashboards.py file should then look something like:
I hope this helps but if not, or you have any further questions please get back in touch. |
Hi JohnThanks for the quick response - will give this a go later today after work and let you know how I get on Rgds,Mike DoddsOn 1 Aug 2023, at 09:44, John Peterson ***@***.***> wrote:
Hi Mike,
Thanks for getting in touch. Basically all you need to do to register your dashboard is add
registry.register(DashboardClassName)
to to bottom of your dashboards.py file. Where DashboardClassName is the Dashboard you have created.
You need to do this for every dashboard you create. So if you had 2 dashboards, DashboardOne and DashboardTwo, set up you would add:
registry.register(DashboardOne)
registry.register(DashboardTwo)
Your final dashboards.py file should then look something like:
from dashboards.dashboard import Dashboard
from dashboards.component import Text, Chart
from dashboards.registry import registry
from demo.mydashboard.data import DashboardData
class FirstDashboard(Dashboard):
welcome = Text(value="Welcome to Django Dashboards!")
animals = Chart(defer=DashboardData.fetch_animals)
class Meta:
name = "First Dashboard"
registry.register(FirstDashboard)
I hope this helps but if not, or you have any further questions please get back in touch.
—Reply to this email directly, view it on GitHub, or unsubscribe.You are receiving this because you authored the thread.Message ID: ***@***.***>
|
Hi John
I’m having issues trying to start the app , i.e. after setup when I run python manage.py runserver. Have checked and did have registry code in my dashboard.py file.
I’ve attached the “ run log” with errors and a summary of steps the setup etc. below
Any help would be great, thanks in advance ,
Mike
_____
1. I’ve done a full clean install in a new folder (new venv, new Django, new Django-dashboard)
am getting the error : "message": "Import \"dashboards.dashboard\" could not be resolved" for the 3 imports (.dashboard . component . registry)
2. For info – when I did the pip install of djnago-dashboard I got an error “ wxpython 4.2.1 requires pillow, which is not installed.” I used pip to install pillow and then ran pip install of Django-dashboard again just in case some additional dependencies were installed after Pillow was in place. None were.
3. Folder structure - Windows
demo
.env
etc
Include
Lib
site-packages :
Scripts
Share
pyenv.cfg
demo
demo
mydashboard
from dashboards.dashboard import dashboard
from dashboards.component import Text, Chart
from dashboards.registry import registry
from demo.mydashboard.data import DashboardData
class FirstDashboard(dashboard):
welcome = Text(value="Welcome to Django Dashboards!")
animals = Chart(defer=DashboardData.fetch_animals)
class Meta:
name = "First Dashboard"
registry.register(FirstDashboard)
From: New Agenorltd ***@***.***>
Sent: Tuesday, August 1, 2023 10:41 AM
To: wildfish/django-dashboards ***@***.***>
Subject: Re: [wildfish/django-dashboards] How do I register my dashboard class ? (Issue #8)
Hi John
Thanks for the quick response - will give this a go later today after work and let you know how I get on
Rgds,
Mike Dodds
On 1 Aug 2023, at 09:44, John Peterson ***@***.*** ***@***.***> > wrote:
Hi Mike,
Thanks for getting in touch. Basically all you need to do to register your dashboard is add
registry.register(DashboardClassName)
to to bottom of your dashboards.py file. Where DashboardClassName is the Dashboard you have created.
You need to do this for every dashboard you create. So if you had 2 dashboards, DashboardOne and DashboardTwo, set up you would add:
registry.register(DashboardOne)
registry.register(DashboardTwo)
Your final dashboards.py file should then look something like:
from dashboards.dashboard import Dashboard
from dashboards.component import Text, Chart
from dashboards.registry import registry
from demo.mydashboard.data import DashboardData
class FirstDashboard(Dashboard):
welcome = Text(value="Welcome to Django Dashboards!")
animals = Chart(defer=DashboardData.fetch_animals)
class Meta:
name = "First Dashboard"
registry.register(FirstDashboard)
I hope this helps but if not, or you have any further questions please get back in touch.
—
Reply to this email directly, view it on GitHub <#8 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/ASSJY26FOEEASLM6QNZ6FQ3XTC6VTANCNFSM6AAAAAA263XXPA> .
You are receiving this because you authored the thread. <https://github.com/notifications/beacon/ASSJY2YMV4LU4QLSKKZ7XPDXTC6VTA5CNFSM6AAAAAA263XXPCWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTC55ID2.gif> Message ID: ***@***.*** ***@***.***> >
Import "demo.mydashboard.data" could not be resolved
Import "dashboards.registry" could not be resolved
Import "dashboards.component" could not be resolved
ERROR: pip's dependency resolver does not currently take into account all the packages that are installed. This behaviour is the source of the following dependency conflicts.
wxpython 4.2.1 requires pillow, which is not installed.
(.env) PS U:\web_devt\demo> python manage.py runserver
Watching for file changes with StatReloader
Exception in thread django-main-thread:
Traceback (most recent call last):
File "C:\Users\midod\AppData\Local\Programs\Python\Python311\Lib\threading.py", line 1038, in _bootstrap_inner
self.run()
File "C:\Users\midod\AppData\Local\Programs\Python\Python311\Lib\threading.py", line 975, in run
self._target(*self._args, **self._kwargs)
File "U:\web_devt\.env\Lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "U:\web_devt\.env\Lib\site-packages\django\core\management\commands\runserver.py", line 125, in inner_run
autoreload.raise_last_exception()
File "U:\web_devt\.env\Lib\site-packages\django\utils\autoreload.py", line 87, in raise_last_exception
raise _exception[1]
File "U:\web_devt\.env\Lib\site-packages\django\core\management\__init__.py", line 394, in execute
autoreload.check_errors(django.setup)()
File "U:\web_devt\.env\Lib\site-packages\django\utils\autoreload.py", line 64, in wrapper
fn(*args, **kwargs)
File "U:\web_devt\.env\Lib\site-packages\django\__init__.py", line 24, in setup
apps.populate(settings.INSTALLED_APPS)
File "U:\web_devt\.env\Lib\site-packages\django\apps\registry.py", line 91, in populate
app_config = AppConfig.create(entry)
^^^^^^^^^^^^^^^^^^^^^^^
File "U:\web_devt\.env\Lib\site-packages\django\apps\config.py", line 193, in create
import_module(entry)
File "C:\Users\midod\AppData\Local\Programs\Python\Python311\Lib\importlib\__init__.py", line 126, in import_module
return _bootstrap._gcd_import(name[level:], package, level)
^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
File "<frozen importlib._bootstrap>", line 1204, in _gcd_import
File "<frozen importlib._bootstrap>", line 1176, in _find_and_load
File "<frozen importlib._bootstrap>", line 1140, in _find_and_load_unlocked
ModuleNotFoundError: No module named 'demo.mydashboard'
|
Hi Mike, It's hard to tell but looks like maybe your virtual env isn't active or using a different one when running the code. If you run How are you running the code? Is it command line or via a code editor like VS Code? You also sent your folder structure but the formatting seems to have messed up. Could you send it again and also show where the manage.py, settings.py and urls.py files live. |
Hi John
Running pip freeze – shows django-dashboards in .env ( listing below )
IDE = VS Code (C:\Users\midod\AppData\Local\Programs\Microsoft VS Code)
Screenshot of IDE and WEB_DEVT Explorer showing demo project, settings.py, manage.py & urls.py
(.env) PS U:\web_devt> pip freeze
asgiref==3.7.2
chardet==5.1.0
crispy-bootstrap4==2022.1
Django==4.2.3
django-cors-headers==4.2.0
django-crispy-forms==2.0
django-dashboards==0.1.4
django-debug-toolbar==4.1.0
django-email-extras==0.3.4
django-excel==0.0.10
djangorestframework==3.14.0
future==0.15.0
lml==0.1.0
numpy==1.25.2
packaging==23.1
pandas==2.0.3
patsy==0.5.3
Pillow==10.0.0
plotly==5.15.0
plotly-express==0.4.1
pyexcel==0.7.0
pyexcel-io==0.6.6
pyexcel-webio==0.1.4
python-dateutil==2.8.2
python-gnupg==0.5.1
pytz==2023.3
scipy==1.11.1
six==1.16.0
sphinx-me==0.3
sqlparse==0.4.4
statsmodels==0.14.0
tenacity==8.2.2
texttable==1.6.7
typing_extensions==4.7.1
tzdata==2023.3
Unidecode==1.3.6
wxPython==4.2.1
(.env) PS U:\web_devt>
From: John Peterson ***@***.***>
Sent: Wednesday, August 2, 2023 10:37 AM
To: wildfish/django-dashboards ***@***.***>
Cc: erewh0 ***@***.***>; Author ***@***.***>
Subject: Re: [wildfish/django-dashboards] How do I register my dashboard class ? (Issue #8)
Hi Mike,
It's hard to tell but looks like maybe your virtual env isn't active or using a different one when running the code.
If you run pip freeze do you see django-dashboards listed?
How are you running the code? Is it command line or via a code editor like VS Code?
You also sent your folder structure but the formatting seems to have messed up. Could you send it again and also show where the manage.py, settings.py and urls.py files live.
—
Reply to this email directly, view it on GitHub <#8 (comment)> , or unsubscribe <https://github.com/notifications/unsubscribe-auth/ASSJY2YSSOA5G3P66LKWA7LXTINSJANCNFSM6AAAAAA263XXPA> .
You are receiving this because you authored the thread. <https://github.com/notifications/beacon/ASSJY27753DDR4BRJNC2YV3XTINSJA5CNFSM6AAAAAA263XXPCWGG33NNVSW45C7OR4XAZNMJFZXG5LFINXW23LFNZ2KUY3PNVWWK3TUL5UWJTTDBYYYK.gif> Message ID: ***@***.*** ***@***.***> >
|
Hi :)
Docs say that after creating my dashboards.py file I need to register your dashboard class in order for it to work with the auto urls..... What exactly do I need to do ? ( am a newbie so prbably a dumb q but.... )
I have a Django app running and would like to add a Dashboard to it... have tried install into that app and also an install into a demo project,. Am blocked at this step ... thanks
Mike
The text was updated successfully, but these errors were encountered: