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,13 +1343,14 @@ def get_admin_or_create(
13431343 nested : bool = True ,
13441344 ) -> Optional [BaseAdminT ]:
13451345 """Get or create admin instance"""
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 )
1346+ admin = self ._registered .get (admin_cls , False )
1347+ if admin is False :
1348+ if nested :
1349+ admin = self ._get_admin_or_create_nested (admin_cls )
1350+ if not admin and (not register or self .__register_lock ):
1351+ return None
13491352 if admin :
13501353 return admin
1351- if not register or self .__register_lock :
1352- return None
13531354 # create admin instance
13541355 admin = admin_cls (self )
13551356 self ._registered [admin_cls ] = admin
@@ -1402,6 +1403,8 @@ def get_model_admin(self, table_name: str) -> Optional[ModelAdmin]:
14021403 if not issubclass (admin_cls , (ModelAdmin , AdminApp )):
14031404 continue
14041405 admin = self .get_admin_or_create (admin_cls , register = False )
1406+ if admin is None :
1407+ continue
14051408 if issubclass (admin_cls , ModelAdmin ) and admin .bind_model and admin .model .__table__ .name == table_name :
14061409 return admin
14071410 elif isinstance (admin , AdminApp ) and self .engine is admin .engine :
You can’t perform that action at this time.
0 commit comments