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
Due to Django's ORM design, database queries must be deferred using hooks. Otherwise, you will see a `SynchronousOnlyOperation` exception.
4
+
5
+
These `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.
6
+
7
+
<!--orm-excp-end-->
8
+
9
+
<!--orm-fetch-start-->
10
+
11
+
By default, automatic recursive fetching of `ManyToMany` or `ForeignKey` fields is enabled within the default `QueryOptions.postprocessor`. This is needed to prevent `SynchronousOnlyOperation` exceptions when accessing these fields within your IDOM components.
Copy file name to clipboardExpand all lines: docs/src/features/components.md
+19-19Lines changed: 19 additions & 19 deletions
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ Convert any Django view into a IDOM component by using this decorator. Compatibl
8
8
9
9
=== "components.py"
10
10
11
-
```python linenums="1"
11
+
```python
12
12
from idom import component, html
13
13
from django.http import HttpResponse
14
14
from django_idom.components import view_to_component
@@ -39,7 +39,7 @@ Convert any Django view into a IDOM component by using this decorator. Compatibl
39
39
40
40
| Type | Description |
41
41
| --- | --- |
42
-
| `_ViewComponentConstructor` | A function that takes `request: HttpRequest | None, *args: Any, key: Key | None, **kwargs: Any` and returns an IDOM component. |
42
+
| `_ViewComponentConstructor` | A function that takes `request, *args, key, **kwargs` and returns an IDOM component. All parameters are directly provided to your view, besides `key` which is used by IDOM. |
43
43
44
44
??? Warning "Potential information exposure when using `compatibility = True`"
45
45
@@ -88,7 +88,7 @@ Convert any Django view into a IDOM component by using this decorator. Compatibl
88
88
89
89
=== "components.py"
90
90
91
-
```python linenums="1"
91
+
```python
92
92
from idom import component, html
93
93
from django.http import HttpResponse
94
94
from django.views import View
@@ -112,7 +112,7 @@ Convert any Django view into a IDOM component by using this decorator. Compatibl
112
112
113
113
=== "components.py"
114
114
115
-
```python linenums="1"
115
+
```python
116
116
from idom import component, html
117
117
from django.http import HttpResponse
118
118
from django_idom.components import view_to_component
@@ -135,7 +135,7 @@ Convert any Django view into a IDOM component by using this decorator. Compatibl
135
135
136
136
=== "components.py"
137
137
138
-
```python linenums="1"
138
+
```python
139
139
from idom import component, html
140
140
from django.http import HttpResponse, HttpRequest
141
141
from django_idom.components import view_to_component
@@ -164,7 +164,7 @@ Convert any Django view into a IDOM component by using this decorator. Compatibl
164
164
165
165
=== "components.py"
166
166
167
-
```python linenums="1"
167
+
```python
168
168
from idom import component, html
169
169
from django.http import HttpResponse
170
170
from django_idom.components import view_to_component
@@ -196,11 +196,9 @@ Convert any Django view into a IDOM component by using this decorator. Compatibl
196
196
197
197
In these scenarios, you may want to rely on best-fit parsing by setting the `strict_parsing` parameter to `False`.
198
198
199
-
Note that best-fit parsing is designed to be similar to how web browsers would handle non-standard or broken HTML.
200
-
201
199
=== "components.py"
202
200
203
-
```python linenums="1"
201
+
```python
204
202
from idom import component, html
205
203
from django.http import HttpResponse
206
204
from django_idom.components import view_to_component
@@ -216,7 +214,7 @@ Convert any Django view into a IDOM component by using this decorator. Compatibl
216
214
)
217
215
```
218
216
219
-
217
+
_Note: Best-fit parsing is designed to be similar to how web browsers would handle non-standard or broken HTML._
220
218
221
219
---
222
220
@@ -226,11 +224,11 @@ Convert any Django view into a IDOM component by using this decorator. Compatibl
226
224
227
225
Any view can be rendered within compatibility mode. However, the `transforms`, `strict_parsing`, `request`, `args`, and `kwargs` arguments do not apply to compatibility mode.
228
226
229
-
Please note that by default the iframe is unstyled, and thus won't look pretty until you add some CSS.
227
+
230
228
231
229
=== "components.py"
232
230
233
-
```python linenums="1"
231
+
```python
234
232
from idom import component, html
235
233
from django.http import HttpResponse
236
234
from django_idom.components import view_to_component
@@ -246,6 +244,8 @@ Convert any Django view into a IDOM component by using this decorator. Compatibl
246
244
)
247
245
```
248
246
247
+
_Note: By default the `compatibility` iframe is unstyled, and thus won't look pretty until you add some CSS._
248
+
249
249
---
250
250
251
251
<font size="4">**`transforms`**</font>
@@ -258,7 +258,7 @@ Convert any Django view into a IDOM component by using this decorator. Compatibl
258
258
259
259
=== "components.py"
260
260
261
-
```python linenums="1"
261
+
```python
262
262
from idom import component, html
263
263
from django.http import HttpResponse
264
264
from django_idom.components import view_to_component
@@ -285,7 +285,7 @@ Allows you to defer loading a CSS stylesheet until a component begins rendering.
285
285
286
286
=== "components.py"
287
287
288
-
```python linenums="1"
288
+
```python
289
289
from idom import component, html
290
290
from django_idom.components import django_css
291
291
@@ -322,7 +322,7 @@ Allows you to defer loading a CSS stylesheet until a component begins rendering.
322
322
323
323
Here's an example on what you should avoid doing for Django static files:
324
324
325
-
```python linenums="1"
325
+
```python
326
326
from idom import component, html
327
327
from django.templatetags.static import static
328
328
@@ -340,7 +340,7 @@ Allows you to defer loading a CSS stylesheet until a component begins rendering.
340
340
341
341
For external CSS, substitute `django_css` with `html.link`.
342
342
343
-
```python linenums="1"
343
+
```python
344
344
from idom import component, html
345
345
346
346
@component
@@ -363,7 +363,7 @@ Allows you to defer loading JavaScript until a component begins rendering. This
363
363
364
364
=== "components.py"
365
365
366
-
```python linenums="1"
366
+
```python
367
367
from idom import component, html
368
368
from django_idom.components import django_js
369
369
@@ -400,7 +400,7 @@ Allows you to defer loading JavaScript until a component begins rendering. This
400
400
401
401
Here's an example on what you should avoid doing for Django static files:
402
402
403
-
```python linenums="1"
403
+
```python
404
404
from idom import component, html
405
405
from django.templatetags.static import static
406
406
@@ -418,7 +418,7 @@ Allows you to defer loading JavaScript until a component begins rendering. This
418
418
419
419
For external JavaScript, substitute `django_js` with `html.script`.
0 commit comments