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
Copy file name to clipboardExpand all lines: README.md
+3-3Lines changed: 3 additions & 3 deletions
Original file line number
Diff line number
Diff line change
@@ -5,7 +5,7 @@
5
5
<!--header-end-->
6
6
<!--intro-start-->
7
7
8
-
Django-IDOM connects your Python project to a ReactJS frontend, allowing you to create **interactive websites without needing JavaScript!**
8
+
Django-IDOM connects your Python project to a ReactJS front-end, allowing you to create **interactive websites without needing JavaScript!**
9
9
10
10
Following ReactJS styling, web elements are combined into [reusable "components"](https://idom-docs.herokuapp.com/docs/guides/creating-interfaces/your-first-components/index.html#parametrizing-components). These components can utilize [hooks](https://idom-docs.herokuapp.com/docs/reference/hooks-api.html) and [events](https://idom-docs.herokuapp.com/docs/guides/adding-interactivity/responding-to-events/index.html#async-event-handlers) to create infinitely complex web pages.
11
11
@@ -25,7 +25,7 @@ Any Python web framework with Websockets can support IDOM. See below for what fr
25
25
26
26
<!--py-header-start-->
27
27
28
-
You'll need a file to define your [IDOM](https://github.com/idom-team/idom) components. We recommend creating a `components.py` file within your chosen **Django app** to start out. Within this file, we will create a simple `hello_world` component.
28
+
You will need a file to define your [IDOM](https://github.com/idom-team/idom) components. We recommend creating a `components.py` file within your chosen **Django app** to start out. Within this file, we will create a simple `hello_world` component.
In your **Django app**'s HTML template, you can now embed your IDOM component using the `component` template tag. Within this tag, you will need to type in your dotted path to the component function as the first argument.
48
48
49
-
Additonally, you can pass in keyword arguments into your component function. For example, after reading the code below, pay attention to how the function definition for `hello_world` (_in the previous example_) accepts a `recipient` argument.
49
+
Additionally, you can pass in keyword arguments into your component function. For example, after reading the code below, pay attention to how the function definition for `hello_world` (_in the previous example_) accepts a `recipient` argument.
Copy file name to clipboardExpand all lines: docs/src/contribute/code.md
+1-1Lines changed: 1 addition & 1 deletion
Original file line number
Diff line number
Diff line change
@@ -2,7 +2,7 @@
2
2
3
3
Everything within the `django-idom` repository must be specific to Django integration. Check out the [IDOM Core documentation](https://idom-docs.herokuapp.com/docs/about/contributor-guide.html) to contribute general features such as: components, hooks, events, and more.
4
4
5
-
If you plan to make code changes to this repository, you'll need to install the following dependencies first:
5
+
If you plan to make code changes to this repository, you will need to install the following dependencies first:
Copy file name to clipboardExpand all lines: docs/src/features/components.md
+13-13Lines changed: 13 additions & 13 deletions
Original file line number
Diff line number
Diff line change
@@ -4,7 +4,7 @@
4
4
5
5
## View To Component
6
6
7
-
Convert any Django view into a IDOM component by usng this decorator. Compatible with [Function Based Views](https://docs.djangoproject.com/en/dev/topics/http/views/) and [Class Based Views](https://docs.djangoproject.com/en/dev/topics/class-based-views/). Views can be sync or async.
7
+
Convert any Django view into a IDOM component by using this decorator. Compatible with [Function Based Views](https://docs.djangoproject.com/en/dev/topics/http/views/) and [Class Based Views](https://docs.djangoproject.com/en/dev/topics/class-based-views/). Views can be sync or async.
8
8
9
9
=== "components.py"
10
10
@@ -30,10 +30,10 @@ Convert any Django view into a IDOM component by usng this decorator. Compatible
30
30
31
31
| Name | Type | Description | Default |
32
32
| --- | --- | --- | --- |
33
-
| view | `Callable | View` | The view function or class to convert. | N/A |
34
-
| compatibility | `bool` | If True, the component will be rendered in an iframe. When using compatibility mode `tranforms`, `strict_parsing`, `request`, `args`, and `kwargs` arguments will be ignored. | `False` |
35
-
| transforms | `Sequence[Callable[[VdomDict], Any]]` | A list of functions that transforms the newly generated VDOM. The functions will be called on each VDOM node. | `tuple` |
36
-
| strict_parsing | `bool` | If True, an exception will be generated if the HTML does not perfectly adhere to HTML5. | `True` |
33
+
| `view` | `Callable | View` | The view function or class to convert. | N/A |
34
+
| `compatibility` | `bool` | If True, the component will be rendered in an iframe. When using compatibility mode `tranforms`, `strict_parsing`, `request`, `args`, and `kwargs` arguments will be ignored. | `False` |
35
+
| `transforms` | `Sequence[Callable[[VdomDict], Any]]` | A list of functions that transforms the newly generated VDOM. The functions will be called on each VDOM node. | `tuple` |
36
+
| `strict_parsing` | `bool` | If True, an exception will be generated if the HTML does not perfectly adhere to HTML5. | `True` |
37
37
38
38
<font size="4">**Returns**</font>
39
39
@@ -45,9 +45,9 @@ Convert any Django view into a IDOM component by usng this decorator. Compatible
45
45
46
46
When using `compatibility` mode, IDOM automatically exposes a URL to your view.
47
47
48
-
It is your responsibility to ensure priveledged information is not leaked via this method.
48
+
It is your responsibility to ensure privileged information is not leaked via this method.
49
49
50
-
This can be done via directly writing conditionals into your view, or by adding decorators such as [user_passes_test](https://docs.djangoproject.com/en/dev/topics/auth/default/#django.contrib.auth.decorators.user_passes_test) to your views prior to using `view_to_component`.
50
+
This can be done via directly writing conditionals into your view, or by adding decorators such as [`user_passes_test`](https://docs.djangoproject.com/en/dev/topics/auth/default/#django.contrib.auth.decorators.user_passes_test) to your views prior to using `view_to_component`.
51
51
52
52
=== "Function Based View"
53
53
@@ -78,7 +78,7 @@ Convert any Django view into a IDOM component by usng this decorator. Compatible
78
78
- Requires manual intervention to change request methods beyond `GET`.
79
79
- IDOM events cannot conveniently be attached to converted view HTML.
80
80
- Does not currently load any HTML contained with a `<head>` tag
81
-
- Has no option to automatically intercept local anchor link (ex. `#!html <a href='example/'></a>`) click events
81
+
- Has no option to automatically intercept local anchor link (such as `#!html <a href='example/'></a>`) click events
82
82
83
83
_Please note these limitations do not exist when using `compatibility` mode._
84
84
@@ -303,8 +303,8 @@ Allows you to defer loading a CSS stylesheet until a component begins rendering.
303
303
304
304
| Name | Type | Description | Default |
305
305
| --- | --- | --- | --- |
306
-
| static_path | `str` | The path to the static file. This path is identical to what you would use on a `static` template tag. | N/A |
307
-
| key | `Key | None` | A key to uniquely identify this component which is unique amongst a component's immediate siblings | `None` |
306
+
| `static_path` | `str` | The path to the static file. This path is identical to what you would use on a `static` template tag. | N/A |
307
+
| `key` | `Key | None` | A key to uniquely identify this component which is unique amongst a component's immediate siblings | `None` |
308
308
309
309
<font size="4">**Returns**</font>
310
310
@@ -318,7 +318,7 @@ Allows you to defer loading a CSS stylesheet until a component begins rendering.
318
318
319
319
??? question "Can I load static CSS using `html.link` instead?"
320
320
321
-
While you can load stylesheets with `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 some visual jankiness, so use this at your own discretion.
321
+
While you can load stylesheets with `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.
322
322
323
323
Here's an example on what you should avoid doing for Django static files:
324
324
@@ -381,8 +381,8 @@ Allows you to defer loading JavaScript until a component begins rendering. This
381
381
382
382
| Name | Type | Description | Default |
383
383
| --- | --- | --- | --- |
384
-
| static_path | `str` | The path to the static file. This path is identical to what you would use on a `static` template tag. | N/A |
385
-
| key | `Key | None` | A key to uniquely identify this component which is unique amongst a component's immediate siblings | `None` |
384
+
| `static_path` | `str` | The path to the static file. This path is identical to what you would use on a `static` template tag. | N/A |
385
+
| `key` | `Key | None` | A key to uniquely identify this component which is unique amongst a component's immediate siblings | `None` |
Copy file name to clipboardExpand all lines: docs/src/features/decorators.md
+2-2Lines changed: 2 additions & 2 deletions
Original file line number
Diff line number
Diff line change
@@ -31,8 +31,8 @@ This decorator can be used with or without parentheses.
31
31
32
32
| Name | Type | Description | Default |
33
33
| --- | --- | --- | --- |
34
-
| auth_attribute | `str` | The value to check within the user object. This is checked in the form of `UserModel.<auth_attribute>`. | `#!python "is_active"` |
35
-
| fallback | `ComponentType`, `VdomDict`, `None` | The `component` or `idom.html` snippet to render if the user is not authenticated. | `None` |
34
+
| `auth_attribute` | `str` | The value to check within the user object. This is checked in the form of `UserModel.<auth_attribute>`. | `#!python "is_active"` |
35
+
| `fallback` | `ComponentType`, `VdomDict`, `None` | The `component` or `idom.html` snippet to render if the user is not authenticated. | `None` |
Copy file name to clipboardExpand all lines: docs/src/features/hooks.md
+9-9Lines changed: 9 additions & 9 deletions
Original file line number
Diff line number
Diff line change
@@ -53,21 +53,21 @@ The function you provide into this hook must return either a `Model` or `QuerySe
53
53
54
54
| Name | Type | Description | Default |
55
55
| --- | --- | --- | --- |
56
-
| query | `Callable[_Params, _Result | None]` | A callable that returns a Django `Model` or `QuerySet`. | N/A |
57
-
| *args | `_Params.args` | Positional arguments to pass into `query`. | N/A |
58
-
| **kwargs | `_Params.kwargs` | Keyword arguments to pass into `query`. | N/A |
56
+
| `query` | `Callable[_Params, _Result | None]` | A callable that returns a Django `Model` or `QuerySet`. | N/A |
57
+
| `*args` | `_Params.args` | Positional arguments to pass into `query`. | N/A |
58
+
| `**kwargs` | `_Params.kwargs` | Keyword arguments to pass into `query`. | N/A |
59
59
60
60
<font size="4">**Returns**</font>
61
61
62
62
| Type | Description |
63
63
| --- | --- |
64
-
| `Query[_Result | None]` | A dataclass containing `loading`/`error` states, your `data` (if the query has successfully executed), and a `refetch` callable that can be used to re-run the query. |
64
+
| `Query[_Result | None]` | An object containing `loading`/`error` states, your `data` (if the query has successfully executed), and a `refetch` callable that can be used to re-run the query. |
65
65
66
66
??? question "Can I make ORM calls without hooks?"
67
67
68
68
Due to Django's ORM design, database queries must be deferred using hooks. Otherwise, you will see a `SynchronousOnlyOperation` exception.
69
69
70
-
This may be resolved in a future version of Django with a natively asynchronous ORM.
70
+
This may be resolved in a future version of Django containing an asynchronous ORM.
71
71
72
72
??? question "Why does the example `get_items` function return a `Model` or `QuerySet`?"
73
73
@@ -128,14 +128,14 @@ The function you provide into this hook will have no return value.
128
128
129
129
| Name | Type | Description | Default |
130
130
| --- | --- | --- | --- |
131
-
| mutate | `Callable[_Params, bool | None]` | A callable that performs Django ORM create, update, or delete functionality. If this function returns `False`, then your `refetch` function will not be used. | N/A |
132
-
| refetch | `Callable[..., Any] | Sequence[Callable[..., Any]] | None` | A `query` function (used by the `use_query` hook) or a sequence of `query` functions that will be called if the mutation succeeds. This is useful for refetching data after a mutation has been performed. | `None` |
131
+
| `mutate` | `Callable[_Params, bool | None]` | A callable that performs Django ORM create, update, or delete functionality. If this function returns `False`, then your `refetch` function will not be used. | N/A |
132
+
| `refetch` | `Callable[..., Any] | Sequence[Callable[..., Any]] | None` | A `query` function (used by the `use_query` hook) or a sequence of `query` functions that will be called if the mutation succeeds. This is useful for refetching data after a mutation has been performed. | `None` |
133
133
134
134
<font size="4">**Returns**</font>
135
135
136
136
| Type | Description |
137
137
| --- | --- |
138
-
| `Mutation[_Params]` | A dataclass containing `loading`/`error` states, a `reset` callable that will set `loading`/`error` states to defaults, and a `execute` callable that will run the query. |
138
+
| `Mutation[_Params]` | An object containing `loading`/`error` states, a `reset` callable that will set `loading`/`error` states to defaults, and a `execute` callable that will run the query. |
139
139
140
140
??? question "Can `use_mutation` trigger a refetch of `use_query`?"
141
141
@@ -240,7 +240,7 @@ The function you provide into this hook will have no return value.
240
240
241
241
Due to Django's ORM design, database queries must be deferred using hooks. Otherwise, you will see a `SynchronousOnlyOperation` exception.
242
242
243
-
This may be resolved in a future version of Django with a natively asynchronous ORM.
243
+
This may be resolved in a future version of Django containing an asynchronous ORM.
244
244
245
245
However, even when resolved it is best practice to perform ORM queries within the `use_query` in order to handle `loading` and `error` states.
0 commit comments