This project I created is more of a template connection that allows a developer to connect Django and Dash from an API endpoint. I store the data throughout a dash application’s DCC.Store in app.py that allows a user to use the data throughout individual pages.
Reason to building project architecture out like this?
Basically Django in my opinion is a strong backend framework and Dash is a strong frontend framework. My approach is to take the best of both combine them and make the development of each framework separate. One of the major weaknesses in web development with Django is mobile development. I setup the dash application to act as a mobile version where Django is focused on API, running scripts, desktop website, and backend development with an admin portal.
I only setup this project to work with a login authentication and get_user_info but I have a boilerplate for the register, refresh_user_token, verify_user_token, account_location, and update_account in the data/ninja_api.py that can be expanded to allow more functionality in the app.py / pages for user’s profile pages and authentication.
Basic setup:
- create and activate an env
pip install -r requirements.txt
- cd into
django_backend
- Connect Postgres database in
django_backend/django_backend/settings.py
python manage.py makemigrations
python manage.py migrate
-python manage.py collectstatic
python manage.py createsuper user
python manage.py runserver
- login to
http://127.0.0.1:8000/admin
and create a profile for your account - run app.py
- go to:
http://127.0.0.1:8000
/ (dash app) - login in from the navbar, creates a modal
- Fetch Data button click to show logged-in account or go to
http://127.0.0.1:8000/profile/
to see the account logged into Dash app.