A Django app to integrate Apache Superset dashboards into a Django application
Project description
django-superset-integration
django-superset-integration is a Django app to integration Apache Superset dashboards into a Django application.
Quick start
- Add
django_superset_integrationto yourINSTALLED_APPSsetting like this:
INSTALLED_APPS = [
...,
"django_superset_integration",
...,
]
- Include the superset-integration URLconf in your project
urls.pylike this:
path("superset_integration/", include("django_superset_integration.urls")),
- You will need a cryptography Fernet key, so you need to install cryptography:
pip install cryptography
- Generate a Fernet key in a python terminal:
from cryptography.fernet import Fernet
FERNET_KEY = Fernet.generate_key()
-
The result is a bytestring like
b'jozEHFGLKJHEFUIHEZ4'. Copy ONLY the content of the string, not the b nor the quotation marks -
In your env variables, create a variable
FERNET_KEYwith the copied content as value -
By default, all dashboard data will be displayed. You can override this by creating your own filtering function and adding it in your
settings.py:
RLS_FUNCTION = "my_app.my_module.create_rls_clause"
Your function must take a parameter user and return a SQL rls clause like this : [{"clause": "1=1"}]
(where you replace 1=1 by the clause you want).
See Superset documentation for more information
-
Make sure that your Superset instance parameter
GUEST_TOKEN_JWT_EXP_SECONDSis more than 300 (5 minutes). Otherwise it will expire before it can be refreshed. For example, set it to 600 (10 minutes). -
In the template where you want to integrate the dashboard, add the following in your
<head>:
<link href="{% static 'css/ponctual-rejects.css' %}" rel="stylesheet"/>
- Then add the following at the emplacement where you want the dashboard:
{% include "django_superset_integration/superset-integration.html" %}
- In your view's
get_context_data, add the following:
dashboard_name = my_dashboard
dashboard = SupersetDashboard.objects.get(name__iexact=dashboard_name)
context["dashboard_integration_id"] = dashboard.integration_id
context["dashboard_id"] = dashboard.id
context["superset_domain"] = dashboard.domain.address
-
Run
python manage.py migrateto create the models. -
Start the development server and visit the admin site to create a
SupersetInstanceobject. -
After you have created a
SupersetInstanceobject, create aSupersetDashboardobject. -
That should be it!
Project details
Release history Release notifications | RSS feed
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_superset_integration-0.1.3.tar.gz.
File metadata
- Download URL: django_superset_integration-0.1.3.tar.gz
- Upload date:
- Size: 8.8 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
a1807738c4ae76504e6afb195343c0d49e519929b79e7346450525c50bdb81c1
|
|
| MD5 |
aea8f64cd803c995aba1c2850248fbc2
|
|
| BLAKE2b-256 |
54b70ca0d887c62d6fd26bd38672fbcb513e30b97469c61ff0856301054a1271
|
File details
Details for the file django_superset_integration-0.1.3-py3-none-any.whl.
File metadata
- Download URL: django_superset_integration-0.1.3-py3-none-any.whl
- Upload date:
- Size: 10.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.10.12
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
b10291c8c77e3775f6df25620a377cce61a78a360a7d2d15b480432309a11e9a
|
|
| MD5 |
51b28607e932d98dc815c6d8657575ee
|
|
| BLAKE2b-256 |
5c03dee6e34aa9a2d4ac8cb887e9ee46e9f3c4507ec5133cb22cfce6dc6c6c71
|