Closed as not planned
Description
Old Behavior
State is generated on a per-render basis and has no method of being permanently stored.
Additionally, there is no convenient way to perform DB queries within components (as of Django 4.1)
New Behavior
Allow for persistent state that is databased backed.
Implementation Details
Persistently store/restore context based on a database model.
The interface should take in a single database object...
from my_django_app.models import GeneralSettings
state, set_state = hooks.use_database_state(GeneralSettings.objects.get(id=20))
state.my_database_field = True
# This saves the values to the database and issues a re-render.
set_state(state)
In the background, the set state is doing the following...
def set_state(state):
state.save()
...
Code of Conduct
- I agree to follow the Code of Conduct.