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: CHANGELOG.md
+6-4
Original file line number
Diff line number
Diff line change
@@ -36,9 +36,11 @@ Don't forget to remove deprecated code on each major release!
36
36
37
37
## [Unreleased]
38
38
39
-
- Nothing (yet)!
39
+
### Changed
40
+
41
+
- Removed dependency on `aiofile`.
40
42
41
-
## [4.0.0]
43
+
## [4.0.0] - 2024-06-22
42
44
43
45
### Added
44
46
@@ -112,8 +114,8 @@ Don't forget to remove deprecated code on each major release!
112
114
- New Django `User` related features!
113
115
-`reactpy_django.hooks.use_user` can be used to access the current user.
114
116
-`reactpy_django.hooks.use_user_data` provides a simplified interface for storing user key-value data.
115
-
-`reactpy_django.decorators.user_passes_test`is inspired by the [equivalent Django decorator](http://docs.djangoproject.com/en/dev/topics/auth/default/#django.contrib.auth.decorators.user_passes_test), but ours works with ReactPy components.
116
-
-`settings.py:REACTPY_AUTO_RELOGIN` will cause component WebSocket connections to automatically [re-login](https://channels.readthedocs.io/en/latest/topics/authentication.html#how-to-log-a-user-in-out) users that are already authenticated. This is useful to continuously update `last_login` timestamps and refresh the [Django login session](https://docs.djangoproject.com/en/dev/topics/http/sessions/).
117
+
-`reactpy_django.decorators.user_passes_test`is inspired by the [equivalent Django decorator](http://docs.djangoproject.com/en/stable/topics/auth/default/#django.contrib.auth.decorators.user_passes_test), but ours works with ReactPy components.
118
+
-`settings.py:REACTPY_AUTO_RELOGIN` will cause component WebSocket connections to automatically [re-login](https://channels.readthedocs.io/en/latest/topics/authentication.html#how-to-log-a-user-in-out) users that are already authenticated. This is useful to continuously update `last_login` timestamps and refresh the [Django login session](https://docs.djangoproject.com/en/stable/topics/http/sessions/).
Copy file name to clipboardExpand all lines: docs/src/learn/add-reactpy-to-a-django-project.md
+8-8
Original file line number
Diff line number
Diff line change
@@ -8,7 +8,7 @@ If you want to add some interactivity to your existing **Django project**, you d
8
8
9
9
!!! abstract "Note"
10
10
11
-
These docs assumes you have already created [a **Django project**](https://docs.djangoproject.com/en/dev/intro/tutorial01/), which involves creating and installing at least one **Django app**.
11
+
These docs assumes you have already created [a **Django project**](https://docs.djangoproject.com/en/stable/intro/tutorial01/), which involves creating and installing at least one **Django app**.
12
12
13
13
If do not have a **Django project**, check out this [9 minute YouTube tutorial](https://www.youtube.com/watch?v=ZsJRXS_vrw0) created by _IDG TECHtalk_.
14
14
@@ -24,7 +24,7 @@ pip install reactpy-django
24
24
25
25
## Step 2: Configure `settings.py`
26
26
27
-
Add `#!python "reactpy_django"` to [`INSTALLED_APPS`](https://docs.djangoproject.com/en/dev/ref/settings/#std:setting-INSTALLED_APPS) in your [`settings.py`](https://docs.djangoproject.com/en/dev/topics/settings/) file.
27
+
Add `#!python "reactpy_django"` to [`INSTALLED_APPS`](https://docs.djangoproject.com/en/stable/ref/settings/#std:setting-INSTALLED_APPS) in your [`settings.py`](https://docs.djangoproject.com/en/stable/topics/settings/) file.
28
28
29
29
=== "settings.py"
30
30
@@ -36,7 +36,7 @@ Add `#!python "reactpy_django"` to [`INSTALLED_APPS`](https://docs.djangoproject
36
36
37
37
ReactPy-Django requires Django ASGI and [Django Channels](https://github.com/django/channels) WebSockets.
38
38
39
-
If you have not enabled ASGI on your **Django project** yet, here is a summary of the [`django`](https://docs.djangoproject.com/en/dev/howto/deployment/asgi/) and [`channels`](https://channels.readthedocs.io/en/stable/installation.html) installation docs:
39
+
If you have not enabled ASGI on your **Django project** yet, here is a summary of the [`django`](https://docs.djangoproject.com/en/stable/howto/deployment/asgi/) and [`channels`](https://channels.readthedocs.io/en/stable/installation.html) installation docs:
40
40
41
41
1. Install `channels[daphne]`
42
42
2. Add `#!python "daphne"` to `#!python INSTALLED_APPS`.
@@ -59,7 +59,7 @@ Add `#!python "reactpy_django"` to [`INSTALLED_APPS`](https://docs.djangoproject
59
59
60
60
## Step 3: Configure `urls.py`
61
61
62
-
Add ReactPy HTTP paths to your `#!python urlpatterns` in your [`urls.py`](https://docs.djangoproject.com/en/dev/topics/http/urls/) file.
62
+
Add ReactPy HTTP paths to your `#!python urlpatterns` in your [`urls.py`](https://docs.djangoproject.com/en/stable/topics/http/urls/) file.
63
63
64
64
=== "urls.py"
65
65
@@ -69,7 +69,7 @@ Add ReactPy HTTP paths to your `#!python urlpatterns` in your [`urls.py`](https:
69
69
70
70
## Step 4: Configure `asgi.py`
71
71
72
-
Register ReactPy's WebSocket using `#!python REACTPY_WEBSOCKET_ROUTE` in your [`asgi.py`](https://docs.djangoproject.com/en/dev/howto/deployment/asgi/) file.
72
+
Register ReactPy's WebSocket using `#!python REACTPY_WEBSOCKET_ROUTE` in your [`asgi.py`](https://docs.djangoproject.com/en/stable/howto/deployment/asgi/) file.
73
73
74
74
=== "asgi.py"
75
75
@@ -97,23 +97,23 @@ Register ReactPy's WebSocket using `#!python REACTPY_WEBSOCKET_ROUTE` in your [`
97
97
98
98
## Step 5: Run database migrations
99
99
100
-
Run Django's [`migrate` command](https://docs.djangoproject.com/en/dev/topics/migrations/) to initialize ReactPy-Django's database table.
100
+
Run Django's [`migrate` command](https://docs.djangoproject.com/en/stable/topics/migrations/) to initialize ReactPy-Django's database table.
101
101
102
102
```bash linenums="0"
103
103
python manage.py migrate
104
104
```
105
105
106
106
## Step 6: Check your configuration
107
107
108
-
Run Django's [`check` command](https://docs.djangoproject.com/en/dev/ref/django-admin/#check) to verify if ReactPy was set up correctly.
108
+
Run Django's [`check` command](https://docs.djangoproject.com/en/stable/ref/django-admin/#check) to verify if ReactPy was set up correctly.
109
109
110
110
```bash linenums="0"
111
111
python manage.py check
112
112
```
113
113
114
114
## Step 7: Create your first component
115
115
116
-
The [next step](./your-first-component.md) will show you how to create your first ReactPy component.
116
+
The [next page](./your-first-component.md) will show you how to create your first ReactPy component.
117
117
118
118
Prefer a quick summary? Read the **At a Glance** section below.
Copy file name to clipboardExpand all lines: docs/src/learn/your-first-component.md
+14-8
Original file line number
Diff line number
Diff line change
@@ -18,7 +18,7 @@ You will now need to pick at least one **Django app** to start using ReactPy-Dja
18
18
19
19
For the following examples, we will assume the following:
20
20
21
-
1. You have a **Django app** named `my_app`, which was created by Django's [`startapp` command](https://docs.djangoproject.com/en/dev/intro/tutorial01/#creating-the-polls-app).
21
+
1. You have a **Django app** named `my_app`, which was created by Django's [`startapp` command](https://docs.djangoproject.com/en/stable/intro/tutorial01/#creating-the-polls-app).
22
22
2. You have placed `my_app` directly into your **Django project** folder (`./example_project/my_app`). This is common for small projects.
23
23
24
24
??? question "How do I organize my Django project for ReactPy?"
@@ -31,7 +31,7 @@ You will need a file to start creating ReactPy components.
31
31
32
32
We recommend creating a `components.py` file within your chosen **Django app** to start out. For this example, the file path will look like this: `./example_project/my_app/components.py`.
33
33
34
-
Within this file, you can define your component functions using ReactPy's`#!python @component` decorator.
34
+
Within this file, you will define your component function(s) using the`#!python @component` decorator.
35
35
36
36
=== "components.py"
37
37
@@ -43,7 +43,7 @@ Within this file, you can define your component functions using ReactPy's `#!pyt
43
43
44
44
We recommend creating a `components.py` for small **Django apps**. If your app has a lot of components, you should consider breaking them apart into individual modules such as `components/navbar.py`.
45
45
46
-
Ultimately, components are referenced by Python dotted path in `my_template.html` ([_see next step_](#embedding-in-a-template)). This path must be valid to Python's `#!python importlib`.
46
+
Ultimately, components are referenced by Python dotted path in `my_template.html` ([_see next step_](#embedding-in-a-template)). This dotted path must be valid to Python's `#!python importlib`.
47
47
48
48
??? question "What does the decorator actually do?"
49
49
@@ -66,25 +66,31 @@ Additionally, you can pass in `#!python args` and `#!python kwargs` into your co
???+ tip "Components are automatically registered!"
70
+
71
+
ReactPy-Django will automatically register any component that is referenced in a Django HTML template. This means you [typically](../reference/utils.md#register-component) do not need to manually register components in your **Django app**.
72
+
73
+
Please note that this HTML template must be properly stored within a registered Django app. ReactPy-Django will output a console log message containing all detected components when the server starts up.
If you do not have a `./templates/` folder in your **Django app**, you can simply create one! Keep in mind, templates within this folder will not be detected by Django unless you [add the corresponding **Django app** to `settings.py:INSTALLED_APPS`](https://docs.djangoproject.com/en/dev/ref/applications/#configuring-applications).
81
+
If you do not have a `./templates/` folder in your **Django app**, you can simply create one! Keep in mind, templates within this folder will not be detected by Django unless you [add the corresponding **Django app** to `settings.py:INSTALLED_APPS`](https://docs.djangoproject.com/en/stable/ref/applications/#configuring-applications).
76
82
77
83
## Setting up a Django view
78
84
79
-
Within your **Django app**'s `views.py` file, you will need to [create a view function](https://docs.djangoproject.com/en/dev/intro/tutorial01/#write-your-first-view) to render the HTML template `my_template.html` ([_from the previous step_](#embedding-in-a-template)).
85
+
Within your **Django app**'s `views.py` file, you will need to [create a view function](https://docs.djangoproject.com/en/stable/intro/tutorial01/#write-your-first-view) to render the HTML template `my_template.html` ([_from the previous step_](#embedding-in-a-template)).
80
86
81
87
=== "views.py"
82
88
83
89
```python
84
90
{% include "../../examples/python/example/views.py" %}
85
91
```
86
92
87
-
We will add this new view into your [`urls.py`](https://docs.djangoproject.com/en/dev/intro/tutorial01/#write-your-first-view) and define what URL it should be accessible at.
93
+
We will add this new view into your [`urls.py`](https://docs.djangoproject.com/en/stable/intro/tutorial01/#write-your-first-view) and define what URL it should be accessible at.
88
94
89
95
=== "urls.py"
90
96
@@ -98,7 +104,7 @@ We will add this new view into your [`urls.py`](https://docs.djangoproject.com/e
98
104
99
105
Once you reach that point, we recommend creating an individual `urls.py` within each of your **Django apps**.
100
106
101
-
Then, within your **Django project's** `urls.py` you will use Django's [`include` function](https://docs.djangoproject.com/en/dev/ref/urls/#include) to link it all together.
107
+
Then, within your **Django project's** `urls.py` you will use Django's [`include` function](https://docs.djangoproject.com/en/stable/ref/urls/#include) to link it all together.
102
108
103
109
## Viewing your component
104
110
@@ -114,7 +120,7 @@ If you copy-pasted our example component, you will now see your component displa
114
120
115
121
??? warning "Do not use `manage.py runserver` for production"
116
122
117
-
This command is only intended for development purposes. For production deployments make sure to read [Django's documentation](https://docs.djangoproject.com/en/dev/howto/deployment/).
123
+
This command is only intended for development purposes. For production deployments make sure to read [Django's documentation](https://docs.djangoproject.com/en/stable/howto/deployment/).
Copy file name to clipboardExpand all lines: docs/src/reference/components.md
+4-4
Original file line number
Diff line number
Diff line change
@@ -124,7 +124,7 @@ Automatically convert a Django view into a component.
124
124
125
125
At this time, this works best with static views with no interactivity.
126
126
127
-
Compatible with sync or async [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/).
127
+
Compatible with sync or async [Function Based Views](https://docs.djangoproject.com/en/stable/topics/http/views/) and [Class Based Views](https://docs.djangoproject.com/en/stable/topics/class-based-views/).
128
128
129
129
=== "components.py"
130
130
@@ -254,7 +254,7 @@ Automatically convert a Django view into an [`iframe` element](https://www.techt
254
254
255
255
The contents of this `#!python iframe` is handled entirely by traditional Django view rendering. While this solution is compatible with more views than `#!python view_to_component`, it comes with different limitations.
256
256
257
-
Compatible with sync or async [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/).
257
+
Compatible with sync or async [Function Based Views](https://docs.djangoproject.com/en/stable/topics/http/views/) and [Class Based Views](https://docs.djangoproject.com/en/stable/topics/class-based-views/).
258
258
259
259
=== "components.py"
260
260
@@ -383,7 +383,7 @@ Compatible with sync or async [Function Based Views](https://docs.djangoproject.
383
383
384
384
## Django CSS
385
385
386
-
Allows you to defer loading a CSS stylesheet until a component begins rendering. This stylesheet must be stored within [Django's static files](https://docs.djangoproject.com/en/dev/howto/static-files/).
386
+
Allows you to defer loading a CSS stylesheet until a component begins rendering. This stylesheet must be stored within [Django's static files](https://docs.djangoproject.com/en/stable/howto/static-files/).
387
387
388
388
=== "components.py"
389
389
@@ -436,7 +436,7 @@ Allows you to defer loading a CSS stylesheet until a component begins rendering.
436
436
437
437
## Django JS
438
438
439
-
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/).
439
+
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/stable/howto/static-files/).
440
440
441
441
<!--
442
442
TODO: This is no longer true since we don't insert elements on the page via JSON Patch anymore.
Copy file name to clipboardExpand all lines: docs/src/reference/decorators.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -12,7 +12,7 @@ Decorator functions can be used within your `components.py` to help simplify dev
12
12
13
13
You can limit component access to users that pass a test function by using this decorator.
14
14
15
-
This decorator is inspired by Django's [`user_passes_test`](http://docs.djangoproject.com/en/dev/topics/auth/default/#django.contrib.auth.decorators.user_passes_test) decorator, but this one works with ReactPy components.
15
+
This only works with ReactPy components, and is inspired by Django's [`user_passes_test`](http://docs.djangoproject.com/en/stable/topics/auth/default/#django.contrib.auth.decorators.user_passes_test) decorator.
Whether to run your synchronous query function in thread sensitive mode. Thread sensitive mode is turned on by default due to Django ORM limitations. See Django's [`sync_to_async` docs](https://docs.djangoproject.com/en/dev/topics/async/#sync-to-async) docs for more information.
79
+
Whether to run your synchronous query function in thread sensitive mode. Thread sensitive mode is turned on by default due to Django ORM limitations. See Django's [`sync_to_async` docs](https://docs.djangoproject.com/en/stable/topics/async/#sync-to-async) docs for more information.
80
80
81
81
This setting only applies to sync query functions, and will be ignored for async functions.
82
82
@@ -129,7 +129,7 @@ Query functions can be sync or async.
129
129
{% include "../../examples/python/use-query-postprocessor-kwargs.py" %}
130
130
```
131
131
132
-
_Note: In Django's ORM design, the field name to access foreign keys is [postfixed with `_set`](https://docs.djangoproject.com/en/dev/topics/db/examples/many_to_one/) by default._
132
+
_Note: In Django's ORM design, the field name to access foreign keys is [postfixed with `_set`](https://docs.djangoproject.com/en/stable/topics/db/examples/many_to_one/) by default._
133
133
134
134
??? question "Can I make ORM calls without hooks?"
135
135
@@ -157,7 +157,7 @@ Query functions can be sync or async.
157
157
158
158
This design decision was based on [Apollo's `#!javascript useQuery` hook](https://www.apollographql.com/docs/react/data/queries/), but ultimately helps avoid Django's `#!python SynchronousOnlyOperation` exceptions.
159
159
160
-
With the `#!python Model` or `#!python QuerySet` your function returns, this hook uses the [default postprocessor](../reference/utils.md#django-query-postprocessor) to ensure that all [deferred](https://docs.djangoproject.com/en/dev/ref/models/instances/#django.db.models.Model.get_deferred_fields) or [lazy](https://docs.djangoproject.com/en/dev/topics/db/queries/#querysets-are-lazy) fields are executed.
160
+
With the `#!python Model` or `#!python QuerySet` your function returns, this hook uses the [default postprocessor](../reference/utils.md#django-query-postprocessor) to ensure that all [deferred](https://docs.djangoproject.com/en/stable/ref/models/instances/#django.db.models.Model.get_deferred_fields) or [lazy](https://docs.djangoproject.com/en/stable/topics/db/queries/#querysets-are-lazy) fields are executed.
161
161
162
162
---
163
163
@@ -217,7 +217,7 @@ Mutation functions can be sync or async.
Whether to run your synchronous mutation function in thread sensitive mode. Thread sensitive mode is turned on by default due to Django ORM limitations. See Django's [`sync_to_async` docs](https://docs.djangoproject.com/en/dev/topics/async/#sync-to-async) docs for more information.
220
+
Whether to run your synchronous mutation function in thread sensitive mode. Thread sensitive mode is turned on by default due to Django ORM limitations. See Django's [`sync_to_async` docs](https://docs.djangoproject.com/en/stable/topics/async/#sync-to-async) docs for more information.
221
221
222
222
This setting only applies to sync query functions, and will be ignored for async functions.
Copy file name to clipboardExpand all lines: docs/src/reference/management-commands.md
+1-1
Original file line number
Diff line number
Diff line change
@@ -10,7 +10,7 @@ ReactPy exposes Django management commands that can be used to perform various R
10
10
11
11
## Clean ReactPy Command
12
12
13
-
Command used to manually clean ReactPy data.
13
+
Command used to manually clean expired ReactPy data from the database and/or cache.
14
14
15
15
When using this command without arguments, it will perform all cleaning operations. You can limit cleaning to specific operations through arguments such as `--sessions`.
0 commit comments