पर्यवेक्षित मशीन अनुवाद
यह सामग्री मानव-निर्मित शब्दावलियों और शैली गाइडों के मार्गदर्शन में मशीन जनरेशन द्वारा अनुवादित की गई है। चूँकि इस पाठ की समीक्षा लाइन-दर-लाइन मैन्युअल रूप से नहीं की गई है, इसलिए कभी-कभी त्रुटियाँ या अनाड़ी वाक्य-रचना हो सकती है।
किसी भी विसंगति की स्थिति में, मूल अंग्रेज़ी संस्करण ही प्रामाणिक स्रोत है।
विजेट्स
विजेट सिस्टम के लिए पूर्ण एट्रिब्यूट और मेथड संदर्भ, जो docstrings से जेनरेट किया गया है। कार्य-उन्मुख मार्गदर्शन के लिए कस्टम व्यू और विजेट और फ़ॉर्म लेआउट देखें।
विजेट, कंपोज़ किए जा सकने वाले और रेंडर हो सकने वाले बिल्डिंग ब्लॉक हैं जिनका उपयोग UI एलिमेंट को डायनैमिक रूप से बनाने के लिए किया जाता है। नीचे सूचीबद्ध हर विजेट क्लास को सीधे starlette_admin से इंपोर्ट किया जा सकता है।
विजेट सिस्टम संदर्भ के अनुसार दो प्रमुख भूमिकाएँ निभाता है:
- डैशबोर्ड और कस्टम पेज: स्टैंडअलोन इंटरफ़ेस और मेट्रिक बोर्ड बनाने के लिए
CustomViewकेwidgetएट्रिब्यूट के रूप में उपयोग किए जाते हैं। - फ़ॉर्म लेआउट: create/edit फ़ॉर्म पर इनपुट को व्यवस्थित और समूहित करने के लिए
BaseModelViewकेform_layoutएट्रिब्यूट के रूप में उपयोग किए जाते हैं।
बेस क्लास
सभी विजेट एक साझा बेस क्लास से इनहेरिट होते हैं, जो स्टैंडर्ड रेंडरिंग और एसेट-कलेक्शन इंटरफ़ेस परिभाषित करता है।
starlette_admin.widgets.BaseWidget
dataclass
Bases: ABC
Base class for all dashboard widgets.
Subclasses set template to a path under the theme's widgets/ directory
and override get_context to supply template variables. Layout widgets
should also override render to recursively render their children before
rendering their own template.
Source code in starlette_admin/widgets.py
additional_css_links(request)
additional_js_links(request)
render(request, env)
async
Render the widget to HTML using env.
Source code in starlette_admin/widgets.py
कंटेंट विजेट
कंटेंट विजेट आपके UI ट्री की लीफ़ नोड्स की तरह काम करते हैं। अन्य विजेट रखने के बजाय ये लाइव डेटा दिखाते हैं। प्रत्येक कंटेंट विजेट एक एसिंक्रोनस कॉलबैक स्वीकार करता है, जो प्रति रिक्वेस्ट एक बार कॉल होता है, जिससे रेंडर किए गए मान हमेशा अद्यतित रहते हैं।
starlette_admin.widgets.StatWidget
dataclass
Bases: BaseWidget
Renders a KPI stat card.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Label shown as the card subheader. |
required |
value_callback
|
Callable[[Request], Awaitable[int | float | str]]
|
Async callable returning the primary metric value. |
required |
link
|
str | None
|
Optional URL; makes the entire card a clickable anchor. |
None
|
description
|
str
|
Secondary text shown below the value. |
''
|
description_icon
|
str
|
Icon class for the description badge
(e.g. |
''
|
color
|
str
|
Tabler color token applied to the description area
(e.g. |
''
|
description_icon_position
|
Literal['before', 'after']
|
|
'after'
|
chart_callback
|
Callable[[Request], Awaitable[dict[str, Any]]] | None
|
Optional async callable returning an ApexCharts |
None
|
chart_type
|
str
|
ApexCharts chart type for the sparkline (default |
'line'
|
chart_height
|
str
|
Height passed to ApexCharts (default |
'40px'
|
chart_options
|
dict[str, Any]
|
Extra ApexCharts options merged over the sparkline defaults. |
dict()
|
countup
|
bool
|
When |
False
|
Source code in starlette_admin/widgets.py
starlette_admin.widgets.ChartWidget
dataclass
Bases: BaseWidget
Renders an ApexCharts chart inside a Tabler card.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Card heading. |
required |
chart_type
|
str
|
ApexCharts chart type, e.g. |
required |
series_callback
|
Callable[[Request], Awaitable[Any]]
|
Async callable returning the ApexCharts |
required |
height
|
int
|
Chart height in pixels (default |
300
|
options
|
dict[str, Any]
|
Extra ApexCharts config merged over the |
dict()
|
Source code in starlette_admin/widgets.py
starlette_admin.widgets.TableWidget
dataclass
Bases: BaseWidget
Renders a compact summary table from a data callback.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Card heading displayed above the table. |
required |
columns
|
list[str]
|
List of column header labels. |
required |
rows_callback
|
Callable[[Request], Awaitable[list[list[Any]]]]
|
Async callable returning rows as a list of lists. |
required |
Source code in starlette_admin/widgets.py
starlette_admin.widgets.TextWidget
dataclass
Bases: BaseWidget
Renders a block of text, optionally as Markdown.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
content
|
str
|
Static markdown or plain text. |
required |
markdown
|
bool
|
Whether to render |
False
|
Source code in starlette_admin/widgets.py
starlette_admin.widgets.HtmlWidget
dataclass
Bases: BaseWidget
Renders an arbitrary block of pre-rendered HTML.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
html
|
str
|
Raw HTML string. It is marked safe and rendered without escaping. |
required |
Source code in starlette_admin/widgets.py
starlette_admin.widgets.DividerWidget
dataclass
Bases: BaseWidget
A horizontal rule / visual separator between other widgets.
Source code in starlette_admin/widgets.py
लेआउट विजेट
लेआउट विजेट कंटेनर होते हैं जिनका उपयोग उनके children (जो कंटेंट विजेट, फ़ॉर्म फ़ील्ड, या अन्य लेआउट विजेट हो सकते हैं) को व्यवस्थित करने के लिए किया जाता है।
स्वचालित एसेट मैनेजमेंट: लेआउट विजेट अपने ट्री को रिकर्सिव रूप से ट्रैवर्स करके अपने children से additional_css_links और additional_js_links कलेक्ट करते हैं। इससे गहराई तक नेस्ट किए गए कंपोनेंट्स भी बिना किसी मैन्युअल वायरिंग के अपनी आवश्यक CSS/JS एसेट स्वतः लोड कर लेते हैं।
starlette_admin.widgets.RowWidget
dataclass
Bases: BaseWidget
Arranges child widgets horizontally in a plain Bootstrap grid row.
Use CardRowWidget instead when every child is itself a card (KPI
stats, charts, tables) and should get Tabler's row-deck row-cards
equal-height-card treatment.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
children
|
list[BaseWidget | Col]
|
Widgets (or |
list()
|
Source code in starlette_admin/widgets.py
starlette_admin.widgets.CardRowWidget
dataclass
Bases: RowWidget
A RowWidget for rows of cards: same layout mechanics, plus
Tabler's row-deck row-cards classes so the cards in the row share a
consistent, equal height. Used for dashboard rows of StatWidget,
ChartWidget, TableWidget, etc.
Source code in starlette_admin/widgets.py
starlette_admin.widgets.ColumnWidget
dataclass
Bases: BaseWidget
Stacks child widgets vertically.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
children
|
list[BaseWidget]
|
Widgets to stack. Also accepts |
list()
|
Source code in starlette_admin/widgets.py
starlette_admin.widgets.GridWidget
dataclass
Bases: BaseWidget
Arranges child widgets in a responsive Bootstrap grid.
Uses Bootstrap's row-cols-* system: Tabler/Bootstrap handles all
responsive behavior; no custom <style> or media queries are emitted.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
children
|
list[BaseWidget]
|
Widgets to render in the grid. Also accepts
|
list()
|
breakpoints
|
Breakpoints
|
Items-per-row at each viewport size. |
(lambda: Breakpoints(default=1))()
|
gutter
|
int
|
Bootstrap gutter scale applied as |
3
|
Source code in starlette_admin/widgets.py
starlette_admin.widgets.PanelWidget
dataclass
Bases: BaseWidget
Wraps child widgets inside a titled card/panel.
When used in a form_layout and resolved down to exactly one visible
field, that field's label is hidden: the panel title already names it,
so the label would be redundant. See
BaseModelView.resolve_form_layout.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
title
|
str
|
Panel heading. |
required |
children
|
list[BaseWidget]
|
Widgets rendered inside the panel body. Also accepts
|
list()
|
collapsible
|
bool
|
Whether the panel can be collapsed. |
False
|
collapsed
|
bool
|
Initial collapsed state (only meaningful when collapsible). |
False
|
icon
|
str
|
Optional icon class for the panel header. |
''
|
Source code in starlette_admin/widgets.py
starlette_admin.widgets.FieldsetWidget
dataclass
Bases: BaseWidget
Wraps child widgets inside a native HTML <fieldset>/<legend>.
Use this instead of PanelWidget when you want the semantics and
plain styling of a form fieldset rather than a card: no shadow, no
header bar, just a bordered group with its legend as the caption.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
legend
|
str
|
Text rendered in the |
required |
children
|
list[BaseWidget]
|
Widgets rendered inside the fieldset. Also accepts
|
list()
|
disabled
|
bool
|
Sets the HTML |
False
|
Source code in starlette_admin/widgets.py
starlette_admin.widgets.TabsWidget
dataclass
Bases: BaseWidget
Renders child widgets as Bootstrap tabs.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
tabs
|
list[tuple[str, BaseWidget]]
|
List of (tab_label, widget) tuples. A tab's |
list()
|
save_state
|
bool
|
Remember the last active tab in the browser's
|
True
|
Source code in starlette_admin/widgets.py
रिस्पॉन्सिव साइज़िंग
विभिन्न स्क्रीन साइज़ पर रिस्पॉन्सिव ग्रिड व्यवहार, कॉलम चौड़ाई और ब्रेकपॉइंट मैनेज करने के लिए समर्पित यूटिलिटी क्लासेस।
starlette_admin.widgets.Breakpoints
dataclass
Bootstrap breakpoint column sizes for Col and GridWidget.
Each field maps to a Bootstrap responsive infix. None (the default)
means the breakpoint is omitted from the generated class string.
For Col, the values are Bootstrap column spans (1-12), or the literal
"auto" for an equal-width flexible column ("col-md" rather than
"col-md-6"):
Breakpoints(default=12, md=6) -> "col-12 col-md-6"
Breakpoints(default=12, md="auto") -> "col-12 col-md"
For GridWidget, the values are items-per-row counts ("auto" does
not apply there):
Breakpoints(default=1, md=2, lg=3) -> "row-cols-1 row-cols-md-2 row-cols-lg-3"
Source code in starlette_admin/widgets.py
starlette_admin.widgets.Col
dataclass
Responsive column wrapper for children of RowWidget.
Wrap a child widget with Col to control its Bootstrap column span at
each viewport size. Omitting breakpoints (or leaving all fields
None) yields an auto col class.
widget accepts the same shorthand as any other widget slot (see
normalize_widget), so Col("email", Breakpoints(md=6)) is
equivalent to Col(FieldRef("email"), Breakpoints(md=6)).
Example::
Col(my_widget, breakpoints=Breakpoints(default=12, md=6))
# -> class="col-12 col-md-6"
Source code in starlette_admin/widgets.py
फ़ॉर्म लेआउट रेफ़रेंस
मॉडल फ़ॉर्म के संदर्भ में विशिष्ट डेटाबेस फ़ील्ड को रेफ़र करने के लिए विशेष रूप से उपयोग किए जाने वाले विजेट।
starlette_admin.widgets.FieldRef
dataclass
Bases: BaseWidget
Leaf widget referencing a declared field by name, for use inside
BaseModelView.form_layout.
FieldRef("email") placed anywhere in a form_layout tree — bare,
or nested inside RowWidget, PanelWidget, TabsWidget, etc. —
means "render the declared email field here". It is not
self-sufficient: the _field/_value/_error attributes are
filled in by BaseModelView.resolve_form_layout from the current
request's obj/errors/field permissions before rendering, so a bare
FieldRef constructed and rendered outside that pipeline has nothing
to show.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
name
|
str
|
Name of the declared field to render. |
required |
show_label
|
bool
|
Whether to render the field's |
True
|
prepend
|
str | None
|
Bootstrap/Tabler input-group addon rendered before the
input, e.g. |
None
|
append
|
str | None
|
Same as |
None
|
flat
|
bool
|
Render the input-group with Tabler's |
False
|
Source code in starlette_admin/widgets.py
शॉर्टहैंड और नॉर्मलाइज़ेशन
आपके लेआउट कोड को साफ़ और अत्यधिक पठनीय रखने के लिए, कंटेनर विजेट स्पष्ट विजेट क्लास इंस्टैंटिएशन के स्थान पर साधारण Python प्रकार स्वीकार करते हैं। इनिशियलाइज़ेशन (__post_init__) के दौरान कंटेनर इन शॉर्टहैंड मानों को स्वतः उनके संबंधित विजेट में बदल देते हैं।
समर्थित शॉर्टहैंड:
str: फ़ील्ड रेफ़रेंस (FieldRef) में बदलता है।tuple: साइड-बाय-साइड रो (RowWidget) में बदलता है।list: वर्टिकल स्टैक (ColumnWidget) में बदलता है।
starlette_admin.widgets.WidgetShorthand = 'BaseWidget | str | tuple[Any, ...] | list[Any]'
module-attribute
Anything a container widget's children (or Col.widget, or a
TabsWidget tab's widget) will accept in place of an already-built
BaseWidget. See normalize_widget for what each shorthand expands to.
starlette_admin.widgets.normalize_widget(node)
Expand a shorthand WidgetShorthand into a real widget.
A bare str becomes a FieldRef referencing the declared field of
that name. A tuple becomes a RowWidget with each item in its own
Col, full width below the md breakpoint and equal width at md and
above (matching how a single item renders full width on its own); if
every item resolves to a StatWidget, a CardRowWidget is used instead
so the cards get the row-deck equal-height treatment. A list becomes a
ColumnWidget stacking each item vertically. Anything else is assumed
to already be a BaseWidget and is returned unchanged.
Each item handed to the resulting RowWidget/ColumnWidget is itself
shorthand-typed, so nesting (a tuple inside a list, a list inside a
tuple, and so on) is expanded in turn by that container's own
__post_init__ when it is constructed below: no explicit recursion is
needed here.
Source code in starlette_admin/widgets.py
हेल्पर
Jinja2 टेम्पलेट या कस्टम कॉन्टेक्स्ट के भीतर विजेट रेंडर करने के लिए यूटिलिटी फ़ंक्शन।
starlette_admin.widgets.render_widget(widget, request, env)
async
Render widget to HTML using env.
This is a convenience helper for custom views that want to render widgets
outside of the default CustomView.widget flow.