File tree Expand file tree Collapse file tree
Expand file tree Collapse file tree Original file line number Diff line number Diff line change @@ -1343,16 +1343,13 @@ def get_admin_or_create(
13431343 nested : bool = True ,
13441344 ) -> Optional [BaseAdminT ]:
13451345 """Get or create admin instance"""
1346- admin = None
1347- if admin_cls not in self ._registered :
1348- if nested :
1349- admin = self ._get_admin_or_create_nested (admin_cls )
1350- if not register or self .__register_lock :
1351- return None
1352- else :
1353- admin = self ._registered .get (admin_cls )
1346+ admin = self ._registered .get (admin_cls , None )
1347+ if admin is None and nested :
1348+ admin = self ._get_admin_or_create_nested (admin_cls )
13541349 if admin :
13551350 return admin
1351+ if not register or self .__register_lock :
1352+ return None
13561353 # create admin instance
13571354 admin = admin_cls (self )
13581355 self ._registered [admin_cls ] = admin
@@ -1371,6 +1368,8 @@ def _get_admin_or_create_nested(
13711368 if not issubclass (app_cls , AdminApp ):
13721369 continue
13731370 app = self .get_admin_or_create (app_cls , register = False , nested = False )
1371+ if app is None :
1372+ continue
13741373 admin = app ._get_admin_or_create_nested (admin_cls )
13751374 if admin :
13761375 return admin
You can’t perform that action at this time.
0 commit comments