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:
4343 except IndexError :
4444 raise ValueError ('Cannot infer model from empty data, please set `Table(..., model=MyModel)`' )
4545
46+ all_model_fields = {** data_model_type .model_fields , ** data_model_type .model_computed_fields }
4647 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+ ]
5351 else :
5452 # add pydantic titles to columns that don't have them
5553 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
6257 return self
6358
6459 @classmethod
You can’t perform that action at this time.
0 commit comments