You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
#### Copyright (c) Reactive Python and affiliates.
4
+
5
+
Permission is hereby granted, free of charge, to any person obtaining a copy of this software and associated documentation files (the "Software"), to deal in the Software without restriction, including without limitation the rights to use, copy, modify, merge, publish, distribute, sublicense, and/or sell copies of the Software, and to permit persons to whom the Software is furnished to do so, subject to the following conditions:
6
+
7
+
The above copyright notice and this permission notice shall be included in all copies or substantial portions of the Software.
8
+
9
+
THE SOFTWARE IS PROVIDED "AS IS", WITHOUT WARRANTY OF ANY KIND, EXPRESS OR IMPLIED, INCLUDING BUT NOT LIMITED TO THE WARRANTIES OF MERCHANTABILITY, FITNESS FOR A PARTICULAR PURPOSE AND NONINFRINGEMENT. IN NO EVENT SHALL THE AUTHORS OR COPYRIGHT HOLDERS BE LIABLE FOR ANY CLAIM, DAMAGES OR OTHER LIABILITY, WHETHER IN AN ACTION OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
Copy file name to clipboardExpand all lines: docs/includes/orm.md
+2-2
Original file line number
Diff line number
Diff line change
@@ -2,12 +2,12 @@
2
2
3
3
Due to Django's ORM design, database queries must be deferred using hooks. Otherwise, you will see a `#!python SynchronousOnlyOperation` exception.
4
4
5
-
These `#!python SynchronousOnlyOperation` exceptions may be resolved in a future version of Django containing an asynchronous ORM. However, it is best practice to always perform ORM calls in the background via hooks.
5
+
These `#!python SynchronousOnlyOperation` exceptions may be removed in a future version of Django. However, it is best practice to always perform IO operations (such as ORM queries) via hooks to prevent performance issues.
6
6
7
7
<!--orm-excp-end-->
8
8
9
9
<!--orm-fetch-start-->
10
10
11
-
By default, automatic recursive fetching of `#!python ManyToMany` or `#!python ForeignKey` fields is enabled within the default `#!python QueryOptions.postprocessor`. This is needed to prevent `#!python SynchronousOnlyOperation` exceptions when accessing these fields within your ReactPy components.
11
+
By default, automatic recursive fetching of `#!python ManyToMany` or `#!python ForeignKey` fields is enabled within the `django_query_postprocessor`. This is needed to prevent `#!python SynchronousOnlyOperation` exceptions when accessing these fields within your ReactPy components.
Copy file name to clipboardExpand all lines: docs/src/reference/components.md
+12-16
Original file line number
Diff line number
Diff line change
@@ -177,7 +177,7 @@ Allows you to defer loading a CSS stylesheet until a component begins rendering.
177
177
178
178
| Name | Type | Description | Default |
179
179
| --- | --- | --- | --- |
180
-
| `#!python static_path` | `#!python str` | The path to the static file. This path is identical to what you would use on a `static` template tag. | N/A |
180
+
| `#!python static_path` | `#!python str` | The path to the static file. This path is identical to what you would use on Django's `#!jinja {% static %}` template tag. | N/A |
181
181
| `#!python key` | `#!python Key | None` | A key to uniquely identify this component which is unique amongst a component's immediate siblings | `#!python None` |
182
182
183
183
<font size="4">**Returns**</font>
@@ -186,10 +186,6 @@ Allows you to defer loading a CSS stylesheet until a component begins rendering.
186
186
| --- | --- |
187
187
| `#!python Component` | A ReactPy component. |
188
188
189
-
??? question "Should I put `#!python django_css` at the top of my HTML?"
190
-
191
-
Yes, if the stylesheet contains styling for your component.
192
-
193
189
??? question "Can I load static CSS using `#!python html.link` instead?"
194
190
195
191
While you can load stylesheets with `#!python html.link`, keep in mind that loading this way **does not** ensure load order. Thus, your stylesheet will be loaded after your component is displayed. This would likely cause unintended visual behavior, so use this at your own discretion.
@@ -204,22 +200,26 @@ Allows you to defer loading a CSS stylesheet until a component begins rendering.
204
200
205
201
`#!python django_css` can only be used with local static files.
206
202
207
-
For external CSS, substitute `#!python django_css` with `#!python html.link`.
203
+
For external CSS, you should use `#!python html.link`.
208
204
209
205
```python
210
206
{% include "../../python/django-css-external-link.py" %}
211
207
```
212
208
213
209
??? question "Why not load my CSS in `#!html <head>`?"
214
210
215
-
Traditionally, stylesheets are loaded in your `#!html <head>` using the `#!jinja {% load static %}` template tag.
211
+
Traditionally, stylesheets are loaded in your `#!html <head>` using Django's `#!jinja {% static %}` template tag.
216
212
217
-
To help improve webpage load times, you can use the `#!python django_css` component to defer loading your stylesheet until it is needed.
213
+
However, to help improve webpage load times you can use this `#!python django_css` component to defer loading your stylesheet until it is needed.
218
214
219
215
## Django JS
220
216
221
217
Allows you to defer loading JavaScript until a component begins rendering. This JavaScript must be stored within [Django's static files](https://docs.djangoproject.com/en/dev/howto/static-files/).
222
218
219
+
!!! warning "Pitfall"
220
+
221
+
Be mindful of load order! If your JavaScript relies on the component existing on the page, you must place `django_js` at the **bottom** of your component.
222
+
223
223
=== "components.py"
224
224
225
225
```python
@@ -232,7 +232,7 @@ Allows you to defer loading JavaScript until a component begins rendering. This
232
232
233
233
| Name | Type | Description | Default |
234
234
| --- | --- | --- | --- |
235
-
| `#!python static_path` | `#!python str` | The path to the static file. This path is identical to what you would use on a `static` template tag. | N/A |
235
+
| `#!python static_path` | `#!python str` | The path to the static file. This path is identical to what you would use on Django's `#!jinja {% static %}` template tag. | N/A |
236
236
| `#!python key` | `#!python Key | None` | A key to uniquely identify this component which is unique amongst a component's immediate siblings | `#!python None` |
237
237
238
238
<font size="4">**Returns**</font>
@@ -241,10 +241,6 @@ Allows you to defer loading JavaScript until a component begins rendering. This
241
241
| --- | --- |
242
242
| `#!python Component` | A ReactPy component. |
243
243
244
-
??? question "Should I put `#!python django_js` at the bottom of my HTML?"
245
-
246
-
Yes, if your scripts are reliant on the contents of the component.
247
-
248
244
??? question "Can I load static JavaScript using `#!python html.script` instead?"
249
245
250
246
While you can load JavaScript with `#!python html.script`, keep in mind that loading this way **does not** ensure load order. Thus, your JavaScript will likely be loaded at an arbitrary time after your component is displayed.
@@ -259,14 +255,14 @@ Allows you to defer loading JavaScript until a component begins rendering. This
259
255
260
256
`#!python django_js` can only be used with local static files.
261
257
262
-
For external JavaScript, substitute `#!python django_js` with `#!python html.script`.
258
+
For external JavaScript, you should use `#!python html.script`.
263
259
264
260
```python
265
261
{% include "../../python/django-js-remote-script.py" %}
266
262
```
267
263
268
264
??? question "Why not load my JS in `#!html <head>`?"
269
265
270
-
Traditionally, JavaScript is loaded in your `#!html <head>` using the `#!jinja {% load static %}` template tag.
266
+
Traditionally, JavaScript is loaded in your `#!html <head>` using Django's `#!jinja {% static %}` template tag.
271
267
272
-
To help improve webpage load times, you can use the `#!python django_js` component to defer loading your JavaScript until it is needed.
268
+
However, to help improve webpage load times you can use this `#!python django_js` component to defer loading your JavaScript until it is needed.
0 commit comments