@@ -803,6 +803,7 @@ def add_view(
803
803
update_schema : Type [BaseModel ],
804
804
update_internal_schema : Optional [Type [BaseModel ]] = None ,
805
805
delete_schema : Optional [Type [BaseModel ]] = None ,
806
+ select_schema : Optional [Type [BaseModel ]] = None ,
806
807
include_in_models : bool = True ,
807
808
allowed_actions : Optional [set [str ]] = None ,
808
809
password_transformer : Optional [Any ] = None ,
@@ -819,6 +820,7 @@ def add_view(
819
820
update_schema: Pydantic schema for update operations
820
821
update_internal_schema: Internal schema for special update cases
821
822
delete_schema: Schema for delete operations
823
+ select_schema: Optional schema for read operations (excludes fields from queries)
822
824
include_in_models: Show in models list in admin UI
823
825
allowed_actions: **Set of allowed operations:**
824
826
- **"view"**: Allow viewing records
@@ -835,6 +837,7 @@ def add_view(
835
837
Notes:
836
838
- Forms are auto-generated with field types determined from Pydantic schemas
837
839
- Actions controlled by allowed_actions parameter
840
+ - Use select_schema to exclude problematic fields (e.g., TSVector) from read operations
838
841
- Use password_transformer for models with password fields that need hashing
839
842
840
843
URL Routes:
@@ -872,6 +875,29 @@ class UserUpdate(BaseModel):
872
875
)
873
876
```
874
877
878
+ Excluding problematic fields (e.g., TSVector):
879
+ ```python
880
+ class DocumentCreate(BaseModel):
881
+ title: str
882
+ content: str
883
+ # TSVector field excluded from this schema
884
+
885
+ class DocumentSelect(BaseModel):
886
+ id: int
887
+ title: str
888
+ content: str
889
+ created_at: datetime
890
+ # search_vector (TSVector) field excluded
891
+
892
+ admin.add_view(
893
+ model=Document,
894
+ create_schema=DocumentCreate,
895
+ update_schema=DocumentCreate,
896
+ select_schema=DocumentSelect, # TSVector field excluded from reads
897
+ allowed_actions={"view", "create", "update"}
898
+ )
899
+ ```
900
+
875
901
User with password handling:
876
902
```python
877
903
from crudadmin.admin_interface.model_view import PasswordTransformer
@@ -1028,6 +1054,7 @@ class Config:
1028
1054
update_schema = update_schema ,
1029
1055
update_internal_schema = update_internal_schema ,
1030
1056
delete_schema = delete_schema ,
1057
+ select_schema = select_schema ,
1031
1058
admin_site = self .admin_site ,
1032
1059
allowed_actions = allowed_actions ,
1033
1060
event_integration = self .event_integration ,
0 commit comments