File tree Expand file tree Collapse file tree 2 files changed +5
-2
lines changed
starlette_admin/contrib/sqla Expand file tree Collapse file tree 2 files changed +5
-2
lines changed Original file line number Diff line number Diff line change @@ -95,7 +95,7 @@ def __init__(
9595 if self .fields is None or len (self .fields ) == 0 :
9696 self .fields = [
9797 self .model .__dict__ [f ].key
98- for f in self .model .__dict__
98+ for f in list ( self .model .__dict__ . keys ())
9999 if type (self .model .__dict__ [f ]) is InstrumentedAttribute
100100 ]
101101 self .fields = (converter or ModelConverter ()).convert_fields_list (
@@ -134,7 +134,7 @@ def _setup_primary_key(self) -> None:
134134 Tuple [InstrumentedAttribute , ...], InstrumentedAttribute
135135 ] = ()
136136 self ._pk_coerce : Union [Tuple [type , ...], type ] = ()
137- for key in self .model .__dict__ :
137+ for key in list ( self .model .__dict__ . keys ()) :
138138 attr = getattr (self .model , key )
139139 if isinstance (attr , InstrumentedAttribute ) and getattr (
140140 attr , "primary_key" , False
Original file line number Diff line number Diff line change 2020 select ,
2121)
2222from sqlalchemy .engine import Engine
23+ from sqlalchemy .ext .associationproxy import association_proxy
2324from sqlalchemy .orm import Session , declarative_base , relationship
2425from sqlalchemy_file .storage import StorageManager
2526from starlette .applications import Starlette
@@ -60,6 +61,8 @@ class User(Base):
6061 name = Column (String (100 ), primary_key = True )
6162 files = Column (sf .FileField (multiple = True ))
6263 products = relationship ("Product" , back_populates = "user" )
64+ # to reproduce https://github.com/jowilf/starlette-admin/issues/507
65+ product_titles = association_proxy ("products" , "titles" )
6366
6467
6568class ProductView (ModelView ):
You can’t perform that action at this time.
0 commit comments