Settings
Overview¶
Your Django project's settings.py
can modify the behavior of ReactPy.
Note
The default configuration of ReactPy is suitable for the vast majority of use cases.
You should only consider changing settings when the necessity arises.
Primary Configuration¶
These are ReactPy-Django's default settings values. You can modify these values in your Django project's settings.py
to change the behavior of ReactPy.
Setting | Default Value | Example Value(s) | Description |
---|---|---|---|
REACTPY_CACHE | "default" | "my-reactpy-cache" | Cache used to store ReactPy web modules. ReactPy benefits from a fast, well indexed cache. We recommend installing redis or python-diskcache . |
REACTPY_DATABASE | "default" | "my-reactpy-database" | Database used to store ReactPy session data. ReactPy requires a multiprocessing-safe and thread-safe database. If configuring REACTPY_DATABASE , it is mandatory to enable our database router like such:DATABASE_ROUTERS = ["reactpy_django.database.Router", ...] |
REACTPY_SESSION_MAX_AGE | 259200 | 0 , 60 , 96000 | Maximum seconds to store ReactPy session data, such as args and kwargs passed into your component template tag. Use 0 to not store any session data. |
REACTPY_URL_PREFIX | "reactpy/" | "rp/" , "render/reactpy/" | The prefix to be used for all ReactPy WebSocket and HTTP URLs. |
REACTPY_DEFAULT_QUERY_POSTPROCESSOR | "reactpy_django.utils.django_query_postprocessor" | None , "example_project.my_query_postprocessor" | Dotted path to the default reactpy_django.hooks.use_query postprocessor function. Postprocessor functions can be async or sync, and the parameters must contain the arg data . Set REACTPY_DEFAULT_QUERY_POSTPROCESSOR to None to globally disable the default postprocessor. |
REACTPY_AUTH_BACKEND | "django.contrib.auth.backends.ModelBackend" | "example_project.auth.MyModelBackend" | Dotted path to the Django authentication backend to use for ReactPy components. This is only needed if: 1. You are using AuthMiddlewareStack and...2. You are using Django's AUTHENTICATION_BACKENDS setting and...3. Your Django user model does not define a backend attribute. |
REACTPY_BACKHAUL_THREAD | False | True | Whether to render ReactPy components in a dedicated thread. This allows the web server to process traffic during ReactPy rendering. Vastly improves throughput with web servers such as hypercorn and uvicorn . |
REACTPY_DEFAULT_HOSTS | None | ["localhost:8000", "localhost:8001", "localhost:8002/subdir" ] | The default host(s) that can render your ReactPy components. ReactPy will use these hosts in a round-robin fashion, allowing for easy distributed computing. You can use the host argument in your template tag as a manual override. |
REACTPY_RECONNECT_INTERVAL | 750 | 100 , 2500 , 6000 | Milliseconds between client reconnection attempts. This value will gradually increase if REACTPY_RECONNECT_BACKOFF_MULTIPLIER is greater than 1 . |
REACTPY_RECONNECT_MAX_INTERVAL | 60000 | 10000 , 25000 , 900000 | Maximum milliseconds between client reconnection attempts. This allows setting an upper bound on how high REACTPY_RECONNECT_BACKOFF_MULTIPLIER can increase the time between reconnection attempts. |
REACTPY_RECONNECT_MAX_RETRIES | 150 | 0 , 5 , 300 | Maximum number of reconnection attempts before the client gives up. |
REACTPY_RECONNECT_BACKOFF_MULTIPLIER | 1.25 | 1 , 1.5 , 3 | Multiplier for the time between client reconnection attempts. On each reconnection attempt, the REACTPY_RECONNECT_INTERVAL will be multiplied by this to increase the time between attempts. You can keep time between each reconnection the same by setting this to 1 . |
Last update: September 7, 2023
Authors: