diff --git a/docs/saved-dashboards.md b/docs/saved-dashboards.md index 8058f1a..d8343d6 100644 --- a/docs/saved-dashboards.md +++ b/docs/saved-dashboards.md @@ -33,3 +33,48 @@ The full list of edit policy options are: - `superuser`: Any user who is a superuser can edit Dashboards belong to the user who created them. Only Django super-users can re-assign ownership of dashboards to other users. + +## JSON export + +If your dashboard is called `/dashboards/demo/` you can add `.json` to get `/dashboards/demo.json` which will return a JSON representation of the dashboard. + +The JSON format looks something like this: + +```json +{ + "title": "Tag word cloud", + "queries": [ + { + "sql": "select \"tag\" as wordcloud_word, count(*) as wordcloud_count from (select blog_tag.tag from blog_entry_tags join blog_tag on blog_entry_tags.tag_id = blog_tag.id\r\nunion all\r\nselect blog_tag.tag from blog_blogmark_tags join blog_tag on blog_blogmark_tags.tag_id = blog_tag.id\r\nunion all\r\nselect blog_tag.tag from blog_quotation_tags join blog_tag on blog_quotation_tags.tag_id = blog_tag.id) as results where tag != 'quora' group by \"tag\" order by wordcloud_count desc", + "rows": [ + { + "wordcloud_word": "python", + "wordcloud_count": 826 + }, + { + "wordcloud_word": "javascript", + "wordcloud_count": 604 + }, + { + "wordcloud_word": "django", + "wordcloud_count": 529 + }, + { + "wordcloud_word": "security", + "wordcloud_count": 402 + }, + { + "wordcloud_word": "datasette", + "wordcloud_count": 331 + }, + { + "wordcloud_word": "projects", + "wordcloud_count": 282 + } + ], + } + ] +} +``` + +Set the `DASHBOARD_DISABLE_JSON` setting to `True` to disable this feature. diff --git a/docs/setup.md b/docs/setup.md index 68970c9..c97f0ec 100644 --- a/docs/setup.md +++ b/docs/setup.md @@ -151,6 +151,7 @@ You can customize the following settings in Django's `settings.py` module: - `DASHBOARD_ROW_LIMIT = 1000` - the maximum number of rows that can be returned from a query. This defaults to 100. - `DASHBOARD_UPGRADE_OLD_BASE64_LINKS` - prior to version 0.8a0 SQL URLs used base64-encoded JSON. If you set this to `True` any hits that include those old URLs will be automatically redirected to the upgraded new version. Use this if you have an existing installation of `django-sql-dashboard` that people already have saved bookmarks for. - `DASHBOARD_ENABLE_FULL_EXPORT` - set this to `True` to enable the full results CSV/TSV export feature. It defaults to `False`. Enable this feature only if you are confident that the database alias you are using does not have write permissions to anything. +- `DASHBOARD_DISABLE_JSON` - set to `True` to disable the feature where `/dashboard/name-of-dashboard.json` provides a JSON representation of the dashboard. This defaults to `False`. ## Custom templates