All notable changes to this project will be documented in this file.
The format is based on Keep a Changelog, and this project adheres to Semantic Versioning.
- Add
reactpy_django.hooks.use_session_statehook for persistent state across WebSocket reconnects.- State is stored in the ReactPy database, so it survives multi-process deployments and round-robin load balancing across hosts.
settings.py:REACTPY_SESSION_STATE_MODEto control whether state is scoped per-tab (default) or per-user.settings.py:REACTPY_SESSION_STATE_SYNC_INTERVAL(default 10 seconds) to control how frequently state is flushed to the database. Set to0to disable periodic syncing so state is only persisted on unmount.settings.py:REACTPY_SESSION_STATE_MAX_AGEto control how long stale session state is retained.settings.py:REACTPY_CLEAN_SESSION_STATEto control whether stale session state is cleaned up during automatic cleanups.
- Automatically serve ReactPy wheel from Django's static directory when using PyScript.
view_to_iframenow renders itsiframewithout aloadingattribute, so it loads eagerly (the HTML default) instead of lazily. Theiframe's document is now fetched as part of the parent page's initial load and is guaranteed to be available as soon as the page loads, rather than being deferred until it is scrolled close to the viewport. To restore the previous lazy-loading behavior, passextra_props={"loading": "lazy"}.- Use one WebSocket per client webpage.
- Updated dependencies:
reactpy>=2.0.0, <3.0.0andreactpy-router>=3.0.0, <4.0.0. - Updated Python support to 3.11–3.14.
- Replaced PyScript
<py-script>tags with standard<script type="py">tags. - Updated the interface for
reactpy.hooks.use_channel_layerto be more intuitive.- Arguments now must be provided as keyworded arguments.
- The
nameargument has been renamed tochannel. - The
group_nameargument has been renamed togroup. - The
group_addandgroup_discardarguments have been removed for simplicity.
- To improve performance,
preactis now used as the default client-side library instead ofreact. - ReactPy v2 compatibility! This release aligns
reactpy-djangowith ReactPy v2's API.- Refactored
DjangoResolverto extendReactPyResolverinstead ofStarletteResolver. - Replaced
web.module_from_file/web.exportwithreactjs.component_from_file. - Replaced
reactpy.backend.typesandreactpy.core.typesimports withreactpy.types. - Renamed
Location.pathnametoLocation.pathandLocation.searchtoLocation.query_string. - Improved
django_formsubmission handling to support multi-value form fields (e.g.,MultipleChoiceField,MultiValueField) by fixing a client-side data serialization issue.
- Refactored
- Removed
reactpy_django.components.pyscript_component. Usereactpy.executors.pyscript.pyscript_componentinstead. - Removed the entire
reactpy_django/pyscript/package (component template, layout handler, and utilities) in favor of ReactPy core's PyScript executor. - Removed
reactpy_django.html.pyscript. Usereactpy.html.py_scriptinstead. - Removed
nest_asynciodependency.
- Resolved bug where
django_formevents would sometimes not occur.
5.2.1 - 2025-01-10
- Use the latest version of
@reactpy/clientwhich includes a fix for needless client-side component re-creation.
5.2.0 - 2024-12-29
- User login/logout features!
reactpy_django.hooks.use_authto provide persistentloginandlogoutfunctionality to your components.settings.py:REACTPY_AUTH_TOKEN_MAX_AGEto control the maximum seconds before ReactPy's login token expires.settings.py:REACTPY_CLEAN_AUTH_TOKENSto control whether ReactPy should clean up expired authentication tokens during automatic cleanups.
- Automatically convert Django forms to ReactPy forms via the new
reactpy_django.components.django_formcomponent! - The ReactPy component tree can now be forcibly re-rendered via the new
reactpy_django.hooks.use_rerenderhook.
- Refactoring of internal code to improve maintainability. No changes to publicly documented API.
- Fixed bug where pre-rendered components could generate a
SynchronousOnlyOperationexception if they access a freshly logged out Django user object.
5.1.1 - 2024-12-02
- Fixed regression from the previous release where components would sometimes not output debug messages when
settings.py:DEBUGis enabled.
- Set upper limit on ReactPy version to
<2.0.0. - ReactPy web modules are now streamed in chunks.
- ReactPy web modules are now streamed using asynchronous file reading to improve performance.
- Performed refactoring to utilize
ruffas this repository's linter.
5.1.0 - 2024-11-24
settings.py:REACTPY_ASYNC_RENDERINGto enable asynchronous rendering of components.
- Bumped the minimum ReactPy version to
1.1.0.
5.0.0 - 2024-10-22
- Now using ReactPy-Router v1 for URL routing, which comes with a slightly different API than before.
- Removed dependency on
aiofile.
- Removed the following deprecated features:
- The
compatibilityargument onreactpy_django.components.view_to_component reactpy_django.components.view_to_componentusage as a decoratorreactpy_django.decorators.auth_requiredreactpy_django.REACTPY_WEBSOCKET_PATHsettings.py:REACTPY_WEBSOCKET_URL
- The
4.0.0 - 2024-06-22
- Client-side Python components can now be rendered via the new
{% pyscript_component %}template tag- You must first call the
{% pyscript_setup %}template tag to load PyScript dependencies
- You must first call the
- Client-side components can be embedded into existing server-side components via
reactpy_django.components.pyscript_component. - Tired of writing JavaScript? You can now write PyScript code that runs directly within client browser via the
reactpy_django.html.pyscriptelement.- This is a viable substitution for most JavaScript code.
-
New syntax for
use_queryanduse_mutationhooks. Here's a quick comparison of the changes:query = use_query(QueryOptions(thread_sensitive=True), get_items, foo="bar") # Old query = use_query(get_items, {"foo":"bar"}, thread_sensitive=True) # New mutation = use_mutation(MutationOptions(thread_sensitive=True), remove_item) # Old mutation = use_mutation(remove_item, thread_sensitive=True) # New
QueryOptionsandMutationOptionshave been removed. The value contained within these objects are now passed directly into the hook.
- Resolved a bug where Django-ReactPy would not properly detect
settings.py:DEBUG.
3.8.1 - 2024-05-07
- Python 3.12 compatibility
3.8.0 - 2024-02-20
- Built-in cross-process communication mechanism via the
reactpy_django.hooks.use_channel_layerhook. - Access to the root component's
idvia thereactpy_django.hooks.use_root_idhook. - More robust control over ReactPy clean up tasks!
settings.py:REACTPY_CLEAN_INTERVALto control how often ReactPy automatically performs cleaning tasks.settings.py:REACTPY_CLEAN_SESSIONSto control whether ReactPy should clean up expired sessions during automatic cleanups.settings.py:REACTPY_CLEAN_USER_DATAto control whether ReactPy should clean up orphaned user data during automatic cleanups.python manage.py clean_reactpycommand to manually perform ReactPy clean up tasks.
- Simplified code for cascading deletion of user data.
3.7.0 - 2024-01-30
- An "offline component" can now be displayed when the client disconnects from the server.
- URL router now supports a
*wildcard to create default routes.
3.6.0 - 2024-01-10
- Built-in Single Page Application (SPA) support!
reactpy_django.router.django_routercan be used to render your Django application as a SPA.
- SEO compatible rendering!
settings.py:REACTPY_PRERENDERcan be set toTrueto make components pre-render by default.- Or, you can enable it on individual components via the template tag:
{% component "..." prerender="True" %}.
- New
view_to_iframefeature!reactpy_django.components.view_to_iframeuses an<iframe>to render a Django view.reactpy_django.utils.register_iframetells ReactPy which viewsview_to_iframecan use.
- New Django
Userrelated features!reactpy_django.hooks.use_usercan be used to access the current user.reactpy_django.hooks.use_user_dataprovides a simplified interface for storing user key-value data.reactpy_django.decorators.user_passes_testis inspired by the equivalent Django decorator, but ours works with ReactPy components.settings.py:REACTPY_AUTO_RELOGINwill cause component WebSocket connections to automatically re-login users that are already authenticated. This is useful to continuously updatelast_logintimestamps and refresh the Django login session.
- Renamed undocumented utility function
ComponentPreloadertoRootComponentFinder. - It is now recommended to call
as_view()when usingview_to_componentorview_to_iframewith Class Based Views. - For thread safety,
thread_sensitive=Truehas been enabled in allsync_to_asyncfunctions where ORM queries are possible. reactpy_django.hooks.use_mutationnow has a__call__method. So rather than writingmy_mutation.execute(...), you can now writemy_mutation(...).
- The
compatibilityargument onreactpy_django.components.view_to_componentis deprecated.- Use
view_to_iframeas a replacement.
- Use
reactpy_django.components.view_to_componentusage as a decorator is deprecated.- Check the docs on how to use
view_to_componentas a function instead.
- Check the docs on how to use
reactpy_django.decorators.auth_requiredis deprecated.- Use
reactpy_django.decorators.user_passes_testinstead. - An equivalent to
auth_required's default is@user_passes_test(lambda user: user.is_active).
- Use
- Fixed a bug where exception stacks would not print on failed component renders.
3.5.1 - 2023-09-07
- Warning W018 (
Suspicious position of 'reactpy_django' in INSTALLED_APPS) has been added.
- The default postprocessor can now disabled by setting
REACTPY_DEFAULT_QUERY_POSTPROCESSORtoNone. - Massive overhaul of docs styling.
3.5.0 - 2023-08-26
- More customization for reconnection behavior through new settings!
REACTPY_RECONNECT_INTERVALREACTPY_RECONNECT_MAX_INTERVALREACTPY_RECONNECT_MAX_RETRIESREACTPY_RECONNECT_BACKOFF_MULTIPLIER
- ReactPy-Django docs are now version controlled via mike!
- Bumped the minimum ReactPy version to
1.0.2. - Prettier WebSocket URLs for components that do not have sessions.
- Template tag will now only validate
args/kwargsifsettings.py:DEBUGis enabled. - Bumped the minimum
@reactpy/clientversion to0.3.1 - Use TypeScript instead of JavaScript for this repository.
- Bumped the minimum Django version to
4.2.
???+ note "Django 4.2+ is required"
ReactPy-Django will continue bumping minimum Django requirements to versions that increase async support.
This "latest-only" trend will continue until Django has all async features that ReactPy benefits from. After this point, ReactPy-Django will begin supporting all maintained Django versions.
settings.py:REACTPY_RECONNECT_MAXis removed. See the docs for the newREACTPY_RECONNECT_*settings.
3.4.0 - 2023-08-18
- Distributed Computing: ReactPy components can now optionally be rendered by a completely separate server!
REACTPY_DEFAULT_HOSTSsetting can round-robin a list of ReactPy rendering hosts.hostargument has been added to thecomponenttemplate tag to force components to render on a specific host.
reactpy_django.utils.register_componentfunction can manually register root components.- Useful if you have dedicated ReactPy rendering application(s) that do not use HTML templates.
- ReactPy will now provide a warning if your HTTP URLs are not on the same prefix as your WebSockets.
- Cleaner logging output for auto-detected ReactPy root components.
reactpy_django.REACTPY_WEBSOCKET_PATHis deprecated. The identical replacement isREACTPY_WEBSOCKET_ROUTE.settings.py:REACTPY_WEBSOCKET_URLis deprecated. The similar replacement isREACTPY_URL_PREFIX.
- Warning W007 (
REACTPY_WEBSOCKET_URL doesn't end with a slash) has been removed. ReactPy now automatically handles slashes. - Warning W008 (
REACTPY_WEBSOCKET_URL doesn't start with an alphanumeric character) has been removed. ReactPy now automatically handles this scenario. - Error E009 (
channels is not in settings.py:INSTALLED_APPS) has been removed. Newer versions ofchannelsdo not require installation viaINSTALLED_APPSto receive an ASGI web server.
3.3.2 - 2023-08-13
- ReactPy WebSocket will now decode messages via
orjsonresulting in an ~6% overall performance improvement. - Built-in
asyncioevent loops are now patched vianest_asyncio, resulting in an ~10% overall performance improvement. This has no performance impact if you are running your web server withuvloop.
- Fix bug where
REACTPY_WEBSOCKET_URLalways generates a warning if unset. - Fixed bug on Windows where
assert f is self._write_futwould be raised byuvicornwhenREACTPY_BACKHAUL_THREAD = True. - Fixed bug on Windows where rendering behavior would be jittery with
daphnewhenREACTPY_BACKHAUL_THREAD = True.
3.3.1 - 2023-08-08
- Additional system checks for ReactPy misconfigurations.
REACTPY_BACKHAUL_THREADnow defaults toFalse.
3.3.0 - 2023-08-05
- Added system checks for a variety of common ReactPy misconfigurations.
REACTPY_BACKHAUL_THREADsetting to enable/disable threading behavior.
- If using
settings.py:REACTPY_DATABASE,reactpy_django.database.Routermust now be registered insettings.py:DATABASE_ROUTERS. - By default, ReactPy will now use a backhaul thread to increase performance.
- Minimum Python version required is now
3.9 - A thread-safe cache is no longer required.
3.2.1 - 2023-06-29
- Template tag exception details are now rendered on the webpage when
settings.py:DEBUGis enabled.
- Prevent exceptions within the
componenttemplate tag from causing the whole template to fail to render.
3.2.0 - 2023-06-08
- Added warning if poor system/cache/database performance is detected while in
DEBUGmode. - Added
REACTPY_AUTH_BACKENDsetting to allow for custom authentication backends.
- Using
SessionMiddlewareStackis now optional. - Using
AuthMiddlewareStackis now optional.
3.1.0 - 2023-05-06
use_querynow supports async functions.use_mutationnow supports async functions.reactpy_django.types.QueryOptions.thread_sensitiveoption to customize how sync queries are executed.reactpy_django.hooks.use_mutationnow acceptsreactpy_django.types.MutationOptionsoption to customize how mutations are executed.
- The
mutateargument onreactpy_django.hooks.use_mutationhas been renamed tomutation.
- Fix bug where ReactPy utilizes Django's default cache timeout, which can prematurely expire the component cache.
3.0.1 - 2023-04-06
reactpy-djangodatabase entries are no longer cleaned during Django application startup. Instead, it will occur on webpage loads ifREACTPY_RECONNECT_MAXseconds has elapsed since the last cleaning.
3.0.0-reactpy - 2023-03-30
django-idomhas been renamed toreactpy-django! Please note that all references to the wordidomin your code should be changed toreactpy. See the docs for more details.
3.0.0 - 2023-03-08
???+ note
This is Django-IDOM's biggest update yet!
To upgrade from previous version you will need to...
1. Install `django-idom >= 3.0.0`
2. Run `idom rewrite-keys <DIR>` and `idom rewrite-camel-case-props <DIR>` to update your `idom.html.*` calls to the new syntax
3. Run `python manage.py migrate` to create the new Django-IDOM database entries
- The
idomclient will automatically configure itself to debug mode depending onsettings.py:DEBUG. use_connectionhook for returning the browser's activeConnection.IDOM_CACHEis now configurable withinsettings.pyto whatever cache name you wish.
- It is now mandatory to run
manage.py migrateafter installing IDOM. - Bumped the minimum IDOM version to 1.0.0. Due to IDOM 1.0.0,
idom.html.*...- HTML properties can now be
snake_case. For exampleclassNamenow becomesclass_name. key=...is now declared within the propsdict(rather than as akwarg).
- HTML properties can now be
- The
componenttemplate tag now supports both positional and keyword arguments. - The
componenttemplate tag now supports non-serializable arguments. IDOM_WS_MAX_RECONNECT_TIMEOUTsetting has been renamed toIDOM_RECONNECT_MAX.
django_idom.hooks.use_websockethas been removed. The similar replacement isdjango_idom.hooks.use_connection.django_idom.types.IdomWebsockethas been removed. The similar replacement isdjango_idom.types.Connection.settings.py:CACHE['idom']is no longer used by default. The name of the cache back-end must now be specified with theIDOM_CACHEsetting.
view_to_componentwill now retain the contents of a<head>tag when rendering.- React client is now set to
productionrather thandevelopment. use_querywill now utilizefield.related_namewhen postprocessing many-to-one relationships.
- Fixed a potential method of component template tag argument spoofing.
- Exception information will no longer be displayed on the page, based on the value of
settings.py:DEBUG.
2.2.1 - 2023-01-09
- Fixed bug where
use_querywould not recursively fetch many-to-one relationships. - IDOM preloader will now print out the exception stack when failing to import a module.
2.2.0 - 2022-12-28
- Add
options: QueryOptionsparameter touse_queryto allow for configuration of this hook.
- By default,
use_querywill recursively prefetch all many-to-many or many-to-one relationships to preventSynchronousOnlyOperationexceptions.
django_idom.hooks._fetch_lazy_fieldshas been deleted. The equivalent replacement isdjango_idom.utils.django_query_postprocessor.
2.1.0 - 2022-11-01
- Minimum
channelsversion is now4.0.0.
- Change type hint on
view_to_componentcallable to haverequestargument be optional. - Change type hint on
view_to_componentto represent it as a decorator with parenthesis (such as@view_to_component(compatibility=True)).
- Add note to docs about potential information exposure via
view_to_componentwhen usingcompatibility=True.
2.0.1 - 2022-10-18
- Ability to use
key=...parameter on all prefabricated components.
2.0.0 - 2022-10-17
use_originhook for returning the browser'slocation.origin.
view_to_componentnow returns aCallable, instead of directly returning aComponent. Check the docs for new usage info.use_mutationanduse_querywill now log any query failures.
- Allow
use_mutationto haverefetch=None, as the docs suggest is possible. use_querywill now prefetch all fields to preventSynchronousOnlyOperationexceptions.view_to_component,django_css, anddjango_jstype hints will now display like normal functions.- IDOM preloader no longer attempts to parse commented out IDOM components.
- Tests are now fully functional on Windows
1.2.0 - 2022-09-19
auth_requireddecorator to prevent your components from rendering to unauthenticated users.use_queryhook for fetching database values.use_mutationhook for modifying database values.view_to_componentutility to convert legacy Django views to IDOM components.
- Bumped the minimum IDOM version to 0.40.2
- Testing suite now uses
playwrightinstead ofselenium
- IDOM preloader is no longer sensitive to whitespace within template tags.
1.1.0 - 2022-07-01
django_cssanddjango_jscomponents to defer loading CSS & JS files until needed.
- Bumped the minimum IDOM version to 0.39.0
1.0.0 - 2022-05-22
- Django specific hooks!
use_websocket,use_scope, anduse_locationare now available within thedjango_idom.hooksmodule. - Documentation has been placed into a formal docs webpage.
- Logging for when a component fails to import, or if no components were found within Django.
idom_componenttemplate tag has been renamed tocomponent- Bumped the minimum IDOM version to 0.38.0
websocketparameter for components has been removed. Functionally, it is replaced withdjango_idom.hooks.use_websocket.
0.0.5 - 2022-04-04
- Bumped the minimum IDOM version to 0.37.2
- ModuleNotFoundError: No module named
idom.core.protocaused by IDOM 0.37.2
0.0.4 - 2022-03-05
- Bumped the minimum IDOM version to 0.37.1
0.0.3 - 2022-02-19
- Bumped the minimum IDOM version to 0.36.3
0.0.2 - 2022-01-30
- Ability to declare the HTML class of the top-level component
div name = ...parameter to IDOM HTTP paths for use withdjango.urls.reverse()- Cache versioning to automatically invalidate old web module files from the cache back-end
- Automatic pre-population of the IDOM component registry
- Type hinting for
IdomWebsocket
- Fetching web modules from disk and/or cache is now fully async
- Static files are now contained within a
django_idom/parent folder - Upgraded IDOM to version
0.36.0 - Minimum Django version required is now
4.0 - Minimum Python version required is now
3.8
IDOM_WEB_MODULES_PATHhas been replaced with Djangoinclude(...)IDOM_WS_MAX_RECONNECT_DELAYhas been renamed toIDOM_WS_MAX_RECONNECT_TIMEOUTidom_web_modulescache back-end has been renamed toidom
- Increase test timeout values to prevent false positives
- Windows compatibility for building Django-IDOM
- Fixed potential directory traversal attack on the IDOM web modules URL
0.0.1 - 2021-08-18
- Support for IDOM within the Django