Views
ModelView class attributes
When subclassing ModelView, these class-level attributes control the generated admin UI:
| Attribute | Type | Description |
|---|---|---|
column_list |
list |
Fields shown as columns in the list view |
column_details_list |
list |
Fields shown on the detail page |
column_searchable_list |
list |
Fields searched when using the search box |
column_sortable_list |
list |
Fields that render a sort link in the list header |
column_filters |
list |
Fields available as filter dropdowns |
form_columns |
list |
Fields included in create/edit forms |
icon |
str |
Sidebar icon name (from the icon set) |
name_plural |
str |
Human-readable plural name shown in the sidebar |
Example:
from hyperadmin.views.dynamic import ModelView
from myapp.models import User
class UserAdmin(ModelView, model=User):
column_list = [User.username, User.email, User.is_active]
column_searchable_list = [User.username, User.email]
column_sortable_list = [User.username, User.created_at]
form_columns = [User.username, User.email, User.first_name, User.last_name]
icon = "person"
name_plural = "Users"
DynamicModelView
The DynamicModelView handles all CRUD views for a registered model: list, detail, create, and update. Routes are generated automatically by HyperAdminRouter.
hyperadmin.views.dynamic.DynamicModelView
Bases: ListViewMixin, DetailViewMixin, CreateViewMixin, UpdateViewMixin, ActionViewMixin
View handler that serves all CRUD endpoints for a registered model.
One instance is created per model by HyperAdminRouter. It delegates
all database operations to its adapter and renders Jinja2 templates
resolved through the template-search hierarchy.
Source code in src/hyperadmin/views/dynamic/core.py
13 14 15 16 17 18 19 20 21 22 23 24 25 | |
PydanticForm
PydanticForm binds a Pydantic/SQLModel class to a set of widgets, validates submitted data, and collects field-level errors for re-rendering.
hyperadmin.views.forms.PydanticForm
Source code in src/hyperadmin/views/forms.py
457 458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 501 502 503 504 505 506 507 508 509 510 511 512 513 514 515 516 517 518 519 520 521 522 523 524 525 526 527 528 529 530 531 532 533 534 535 536 537 538 539 540 541 542 543 544 545 546 547 548 549 550 551 552 553 554 555 556 557 558 559 560 561 562 563 564 565 566 567 568 569 570 571 572 573 574 575 576 577 578 579 580 581 582 583 584 585 586 587 588 589 590 591 592 593 594 595 596 597 598 599 600 601 602 603 604 605 606 607 608 609 610 611 612 613 614 615 616 617 618 619 620 621 622 623 624 625 626 627 628 629 630 631 632 633 634 635 636 637 638 639 640 641 642 643 644 645 646 647 648 649 650 651 652 653 654 655 656 657 658 659 660 661 662 663 664 665 666 667 668 669 670 671 672 673 674 675 676 677 678 679 680 681 682 683 684 685 686 687 688 689 690 691 692 693 694 695 696 697 698 699 700 701 702 703 704 705 706 707 708 709 710 711 712 713 714 715 716 717 718 719 720 721 722 723 724 725 726 727 728 729 730 731 732 733 734 735 736 737 738 739 740 741 742 743 744 745 746 747 748 749 750 751 752 753 754 755 756 757 758 759 760 761 762 763 764 765 766 767 768 769 770 771 772 773 774 775 776 777 778 779 | |
auto_now_field_names
property
Names of model fields hidden from the form because they stamp "now".
An update must not write these: validation would fill them from their default factory and overwrite the stored timestamp.
fieldset_groups
property
Return form fields grouped according to the configured fieldsets.
If no fieldsets are configured, returns a single group containing all fields. Fields referenced in a fieldset spec but not present in the form are silently skipped. Fields not covered by any fieldset are collected into a trailing "Other fields" group.
layout_css_class
property
Return the CSS class for the form layout.
Returns ha-form-grid-2 for two-column layout, empty string for single.
__init__(model, *, widgets=None, include=None, exclude=None, initial=None, choices_base_url='', fieldsets=None, form_layout=None, form_fields=None, pk_attr='id', pk_editable=False, timezone=dt_timezone.utc, datetime_kind=None)
Build a form over model's fields.
Parameters:
| Name | Type | Description | Default |
|---|---|---|---|
pk_attr
|
str
|
The model's primary-key attribute; skipped unless |
'id'
|
pk_editable
|
bool
|
Render the primary key as an input. Set only on create forms of models whose key is not generated (a natural key). |
False
|
timezone
|
tzinfo
|
The display timezone for datetime input. |
utc
|
datetime_kind
|
Callable[[str], DateTimeKind | None] | None
|
Resolves a field to |
None
|
Source code in src/hyperadmin/views/forms.py
458 459 460 461 462 463 464 465 466 467 468 469 470 471 472 473 474 475 476 477 478 479 480 481 482 483 484 485 486 487 488 489 490 491 492 493 494 495 496 497 498 499 500 | |
HtmxWidget
The base widget class. Pairs a Jinja2 template with optional HTMX attributes and static assets.
hyperadmin.views.forms.HtmxWidget
dataclass
A minimal widget abstraction capable of rendering via a Jinja template.
template_path: path to template included under the project templates directory.
static_list: optional JS/CSS assets to include once per page.
htmx_attrs: optional HTMX attributes to include on the input element.
input_type: HTML input type string returned to templates (e.g. "text", "number").
Source code in src/hyperadmin/views/forms.py
77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 | |