File tree Expand file tree Collapse file tree 1 file changed +7
-12
lines changed
src/python-fastui/fastui/components Expand file tree Collapse file tree 1 file changed +7
-12
lines changed Original file line number Diff line number Diff line change @@ -43,22 +43,17 @@ def _fill_columns(self) -> _te.Self:
43
43
except IndexError :
44
44
raise ValueError ('Cannot infer model from empty data, please set `Table(..., model=MyModel)`' )
45
45
46
+ all_model_fields = {** data_model_type .model_fields , ** data_model_type .model_computed_fields }
46
47
if self .columns is None :
47
- self .columns = []
48
- for name , field in data_model_type .model_fields .items ():
49
- self .columns .append (display .DisplayLookup (field = name , title = field .title ))
50
- for name , field in data_model_type .model_computed_fields .items ():
51
- self .columns .append (display .DisplayLookup (field = name , title = field .title ))
52
-
48
+ self .columns = [
49
+ display .DisplayLookup (field = name , title = field .title ) for name , field in all_model_fields .items ()
50
+ ]
53
51
else :
54
52
# add pydantic titles to columns that don't have them
55
53
for column in (c for c in self .columns if c .title is None ):
56
- model_field = data_model_type .model_fields .get (column .field )
57
- computed_field = data_model_type .model_computed_fields .get (column .field )
58
- if model_field and model_field .title :
59
- column .title = model_field .title
60
- elif computed_field and computed_field .title :
61
- column .title = computed_field .title
54
+ field = all_model_fields .get (column .field )
55
+ if field and field .title :
56
+ column .title = field .title
62
57
return self
63
58
64
59
@classmethod
You can’t perform that action at this time.
0 commit comments