queryset_component
django_spire.core.components.scroll.queryset_component
ITEM_NAME_PREFIX = 'item_'
module-attribute
QuerySetScrollComponent
Bases: BaseScrollComponent, ABC
A :class:BaseScrollComponent whose items are the rows of a queryset.
Subclasses return the rows from get_queryset(). The primary key
identifies each row and is appended to the queryset's ordering, so that
the order is total; a queryset with no ordering is listed by primary key.
Each item is a model instance.
glue_items sends each row to the browser as the Glue model
get_glue_item() builds, in place of rendering it on the server, so
the row markup can call the model's Glue methods. The rows are drawn in
the browser: item_template is Alpine markup that reads item, drawn
by the scroll_item block of the component template, which a list may
fill in itself instead. The browser then loads rows with
load_glue_items() and load_glue_item(), and the other loads are
refused.
Glue rows never arrive with the render: a Glue child is not derived again
when its component refreshes, so every batch comes from
load_glue_items(). A batch holds up to batch_size rows, and a full
one means there may be more.
glue_items = False
class-attribute
model_name
cached
property
verbose_name
cached
property
verbose_name_plural
cached
property
renders_items_on_server
property
__init_subclass__
Source code in django_spire/core/components/scroll/queryset_component.py
get_queryset
abstractmethod
get_permission_model
Return the listed model, whose permissions Glue.ModelAccessMixin reads.
get_items
Source code in django_spire/core/components/scroll/queryset_component.py
get_item
get_item_key
get_instance
Return the row of get_queryset() with this primary key, for a
callable that acts on one row. A row that is not in the list is
reported as Glue's model_instance_not_found, a 404.
Source code in django_spire/core/components/scroll/queryset_component.py
get_glue_item
Return the Glue model the browser receives for item when
glue_items is set, built with name as its unique name and with
exactly the fields, access and form the row needs. A list that sets
glue_items must override it.
To edit a row in place, pass the row a form, bind the row's inputs
to item.form, and save with the form's own method, such as
item.form.save_model_obj(). That runs the form's validation and
whatever the application's save does. item.save() writes the model
directly instead.