Skip to content

Commit

Permalink
Improved docs formatting
Browse files Browse the repository at this point in the history
  • Loading branch information
marksweb committed Jun 8, 2021
1 parent 905632f commit 62d30d8
Show file tree
Hide file tree
Showing 4 changed files with 168 additions and 155 deletions.
2 changes: 1 addition & 1 deletion docs/conf.py
Original file line number Diff line number Diff line change
Expand Up @@ -66,8 +66,8 @@
"simple, and confusion-free.",
"github_user": "groveco",
"github_repo": "django-sql-explorer",
"fixed_sidebar": True
}
pygments_style = 'sphinx'

# Add any paths that contain custom static files (such as style sheets) here,
# relative to this directory. They are copied after the builtin static files,
Expand Down
32 changes: 22 additions & 10 deletions docs/features.rst
Original file line number Diff line number Diff line change
Expand Up @@ -89,21 +89,27 @@ Schema Helper
set ``EXPLORER_ENABLE_TASKS`` and ``EXPLORER_ASYNC_SCHEMA`` to
``True``.

.. _Template Columns:

Template Columns
----------------
- Let's say you have a query like 'select id, email from user' and
- Let's say you have a query like ``SELECT id, email FROM user`` and
you'd like to quickly drill through to the profile page for each
user in the result. You can create a "template" column to do
user in the result. You can create a ``template`` column to do
just that.
- Just set up a template column in your settings file:

``EXPLORER_TRANSFORMS = [('user', '<a href="https://yoursite.com/profile/{0}/">{0}</a>')]``
.. code-block:: python
EXPLORER_TRANSFORMS = [
('user', '<a href="https://yoursite.com/profile/{0}/">{0}</a>')
]
- And change your query to ``SELECT id AS "user", email FROM
user``. Explorer will match the "user" column alias to the
user``. Explorer will match the ``user`` column alias to the
transform and merge each cell in that column into the template
string. Cool!
- Note you *must* set ``EXPLORER_UNSAFE_RENDERING`` to ``True`` if you
string. `Cool!`
- Note you **must** set ``EXPLORER_UNSAFE_RENDERING`` to ``True`` if you
want to see rendered HTML (vs string literals) in the output.
And be aware of the implications of enabling that setting.

Expand Down Expand Up @@ -149,10 +155,12 @@ Multiple Connections
way. See connections.py for more documentation on
multi-connection setup.

.. _Power tips:

Power tips
----------
- On the query listing page, focus gets set to a search box so you
can just navigate to /explorer and start typing the name of your
can just navigate to ``/explorer`` and start typing the name of your
query to find it.
- Quick search also works after hitting "Show Schema" on a query
view.
Expand Down Expand Up @@ -180,8 +188,12 @@ Power tips
``EXPLORER_TOKEN=<SOME TOKEN>`` and you have an instant data
API. Just:

``curl --header "X-API-TOKEN: <TOKEN>" https://www.your-site.com/explorer/<QUERY_ID>/stream?format=csv``
.. code-block:: console
curl --header "X-API-TOKEN: <TOKEN>" https://www.your-site.com/explorer/<QUERY_ID>/stream?format=csv
You can also pass the token with a query parameter like this:

You can also pass the token with a query parameter like this:
.. code-block:: console
``curl https://www.your-site.com/explorer/<QUERY_ID>/stream?format=csv&token=<TOKEN>``
curl https://www.your-site.com/explorer/<QUERY_ID>/stream?format=csv&token=<TOKEN>
13 changes: 10 additions & 3 deletions docs/install.rst
Original file line number Diff line number Diff line change
@@ -1,7 +1,8 @@
Install
=======

Requires Python 3.6 or higher. Requires Django 2.2 or higher.
* Requires Python 3.6 or higher.
* Requires Django 2.2 or higher.

Set up a Django project with the following:

Expand All @@ -14,15 +15,20 @@ More information in the `django tutorial <https://docs.djangoproject.com/en/3.1/

Install with pip from pypi:

``pip install django-sql-explorer``
.. code-block:: shell-session
$ pip install django-sql-explorer
If you would also like to support downloading Excel files install with the dependency using:

``pip install django-sql-explorer[xls]``
.. code-block:: shell-session
$ pip install django-sql-explorer[xls]
Add to your ``INSTALLED_APPS``, located in the ``settings.py`` file in your project folder:

.. code-block:: python
:emphasize-lines: 3
INSTALLED_APPS = (
...,
Expand All @@ -35,6 +41,7 @@ via the ``EXPLORER_PERMISSION_VIEW`` and ``EXPLORER_PERMISSION_CHANGE``
settings. See Settings section below for further documentation.):

.. code-block:: python
:emphasize-lines: 5
from django.urls import path
Expand Down
Loading

0 comments on commit 62d30d8

Please sign in to comment.