Components API Reference
All component base classes live in dj_design_system.components. Any new
component class added to that module will appear here automatically.
dj_design_system.components
BaseComponent(**kwargs)
Source code in dj_design_system/components.py
54 55 56 57 58 59 60 | |
__init_subclass__(**kwargs)
Validate Meta constraint declarations at class definition time.
Source code in dj_design_system/components.py
30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 50 51 52 | |
docstring()
classmethod
Return a string describing the API of this component, including its parameters and their types.
Source code in dj_design_system/components.py
172 173 174 175 176 177 178 179 180 181 | |
get_app_label()
classmethod
Return the app label this component was discovered in.
Source code in dj_design_system/components.py
190 191 192 193 194 195 | |
get_available_themes()
classmethod
Return the list of theme values supported by this component.
Source code in dj_design_system/components.py
218 219 220 221 222 223 224 225 226 227 228 229 230 231 232 233 234 235 | |
get_classes_string()
Get a string of CSS classes based on the context.
Source code in dj_design_system/components.py
130 131 132 133 134 135 136 | |
get_context()
Get the context for rendering the component.
Source code in dj_design_system/components.py
95 96 97 98 99 100 101 102 103 104 105 106 107 108 109 110 111 112 113 114 115 116 117 118 119 120 121 122 123 124 125 126 127 128 | |
get_media()
classmethod
Return the CSS and JS static URL paths required by this component.
Source code in dj_design_system/components.py
204 205 206 207 208 209 | |
get_name()
classmethod
Return the component's registered name from the registry.
Source code in dj_design_system/components.py
183 184 185 186 187 188 | |
get_params()
classmethod
Get the parameters for this component, cached per class.
Source code in dj_design_system/components.py
159 160 161 162 163 164 165 166 167 168 169 170 | |
get_positional_args()
classmethod
Return the list of positional arg names from the class's own Meta.positional_args.
Source code in dj_design_system/components.py
211 212 213 214 215 216 | |
get_relative_path()
classmethod
Return the relative path within the app's components directory.
Source code in dj_design_system/components.py
197 198 199 200 201 202 | |
map_positional_args(positional_args, args, kwargs)
staticmethod
Map positional arguments to keyword arguments using the positional_args spec.
Source code in dj_design_system/components.py
237 238 239 240 241 242 243 244 245 | |
param_has_been_set(param_name)
Return True if the parameter has been explicitly set on this component instance.
Source code in dj_design_system/components.py
66 67 68 69 70 71 | |
render()
Render the component as an HTML string.
Source code in dj_design_system/components.py
138 139 140 141 142 143 | |
validate_params()
An override hook allowing param combinations or values to raise exceptions if necessary
Source code in dj_design_system/components.py
62 63 64 | |
BlockComponent(content=None, *, slots=None, **kwargs)
Bases: BaseComponent
A component registered as a Django simple_block_tag.
Source code in dj_design_system/components.py
285 286 287 288 289 290 291 292 293 294 295 296 297 298 299 300 301 | |
as_tag()
classmethod
Return a template tag function or compilation function.
Source code in dj_design_system/components.py
325 326 327 328 329 330 331 332 333 334 335 336 337 338 | |
get_context()
Add content or slot values to the context automatically.
Source code in dj_design_system/components.py
303 304 305 306 307 308 309 310 311 | |
get_slots()
classmethod
Return the declared slots dict from Meta, or empty dict.
Source code in dj_design_system/components.py
319 320 321 322 323 | |
has_slots()
classmethod
Return True if this component declares named slots via Meta.slots.
Source code in dj_design_system/components.py
313 314 315 316 317 | |
TagComponent(**kwargs)
Bases: BaseComponent
A component registered as a Django simple_tag.
Source code in dj_design_system/components.py
54 55 56 57 58 59 60 | |
as_tag()
classmethod
Return a template tag function mapping positional args via Meta.positional_args.
Source code in dj_design_system/components.py
265 266 267 268 269 270 271 272 273 274 | |
options: members: true show_root_heading: false show_source: true show_symbol_type_heading: true show_symbol_type_toc: true docstring_style: google merge_init_into_class: true group_by_category: true
Slots API
dj_design_system.slots
Named slot support for BlockComponent.
A slot defines a named content area that template authors fill using
{% slot "name" %}...{% endslot %} tags inside a block component.
Slot(required=False, default='', description='')
Declaration of a named content slot on a BlockComponent.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
required
|
bool
|
Whether the slot must be provided. Defaults to False. |
False
|
default
|
str
|
Default content when the slot is not provided. Only
meaningful when |
''
|
description
|
str
|
Human-readable description for documentation/gallery. |
''
|
Source code in dj_design_system/slots.py
25 26 27 28 29 30 31 32 33 | |
validate_slots(declared_slots, provided_slots, component_name)
Validate provided slots against a component's declared slots.
Returns a complete dict of slot values (filling in defaults for missing optional slots).
Raises:
| Type | Description |
|---|---|
ValueError
|
If a required slot is missing, an unknown slot name is used, or a slot name appears more than once. |
Source code in dj_design_system/slots.py
43 44 45 46 47 48 49 50 51 52 53 54 55 56 57 58 59 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 | |
options: members: true show_root_heading: false show_source: true show_symbol_type_heading: true show_symbol_type_toc: true docstring_style: google merge_init_into_class: true