Skip to content

Commit cfc7f06

Browse files
delsimGibbsConsulting
authored andcommitted
Update tag documentation (#78)
* Add middleware comments for template tags * Added more template docs * Minor improvements to template documentation
1 parent ed13d11 commit cfc7f06

File tree

2 files changed

+29
-7
lines changed

2 files changed

+29
-7
lines changed

docs/installation.rst

Lines changed: 3 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -17,6 +17,9 @@ Then, add ``django_plotly_dash`` to ``INSTALLED_APPS`` in the Django ``settings.
1717
...
1818
]
1919

20+
Further, if the :ref:`header and footer <plotly_header_footer>` tags are in use
21+
then ``django_plotly_dash.middleware.BaseMiddleware`` should be added to ``MIDDLEWARE`` in the same file. This can be safely added now even if not used.
22+
2023
The project directory name ``django_plotly_dash`` can also be used on its own if preferred, but this will stop the use of readable application names in
2124
the Django admin interface.
2225

docs/template_tags.rst

Lines changed: 26 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -68,16 +68,18 @@ the page there are no arguments to control the size of the iframe.
6868

6969
This tag should not appear more than once on a page. This rule however is not enforced at present.
7070

71-
.. _plotly_message_pipe:
71+
If this tag is used, then the :ref:`header and footer <plotly_header_footer>` tags should also be
72+
added to the template. Note that these tags in turn have middleware requirements.
7273

74+
.. _plotly_header_footer:
7375

74-
The ``plotly_header`` and ``plotly_footer`` template tag
75-
--------------------------------------------------------
76+
The ``plotly_header`` and ``plotly_footer`` template tags
77+
---------------------------------------------------------
7678

7779
``DjangoDash`` allows you to inject directly the html generated by ``Dash`` in
78-
the DOM of the page (without iframe). To include your app CSS and JS, you have
79-
to include 2 tags in your template ``plotly_header`` and ``plotly_footer``, as
80-
folllows:
80+
the DOM of the page without wrapping it in an iframe. To include your app CSS and JS, you have
81+
to include two tags in your template, namely ``plotly_header`` and ``plotly_footer``, as
82+
follows:
8183

8284
.. code-block:: jinja
8385
@@ -100,9 +102,26 @@ folllows:
100102
{% plotly_footer %}
101103
</html>
102104
103-
This part in mandatory if you want to use ``plotly_direct`` tag.
105+
This part in mandatory if you want to use the :ref:`plotly_direct <plotly_direct>` tag, and these two tags can safely be included
106+
on any page that has loaded the ``plotly_dash`` template tag library with minimal overhead. Neither tag has
107+
any arguments.
108+
109+
Note that if you are using any functionality that needs the use of these tags, then the associated middleware
110+
should be added in ``settings.py`` as mentioned in the :ref:`installation <installation>` section.
111+
112+
.. code-block:: python
113+
114+
MIDDLEWARE = [
115+
...
104116
117+
'django_plotly_dash.middleware.BaseMiddleware',
105118
119+
]
120+
121+
122+
This middleware should appear low down the middleware list.
123+
124+
.. _plotly_message_pipe:
106125

107126
The ``plotly_message_pipe`` template tag
108127
----------------------------------------

0 commit comments

Comments
 (0)