Skip to content

use_database_state hook #39

Closed as not planned
Closed as not planned
@Archmonger

Description

@Archmonger

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

Metadata

Metadata

Assignees

No one assigned

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions