Skip to content

Commit

Permalink
Raise proper exception if no child models are available
Browse files Browse the repository at this point in the history
  • Loading branch information
piranna committed Feb 16, 2024
1 parent fa6bc9f commit f075aab
Showing 1 changed file with 6 additions and 1 deletion.
7 changes: 6 additions & 1 deletion polymorphic/admin/parentadmin.py
Original file line number Diff line number Diff line change
Expand Up @@ -123,9 +123,14 @@ def get_child_type_choices(self, request, action):
Return a list of polymorphic types for which the user has the permission to perform the given action.
"""
self._lazy_setup()

child_models = self.get_child_models()
if not child_models:
raise ImproperlyConfigured("No child models are available.")

choices = []
content_types = ContentType.objects.get_for_models(
*self.get_child_models(), for_concrete_models=False
*child_models, for_concrete_models=False
)

for model, ct in content_types.items():
Expand Down

0 comments on commit f075aab

Please sign in to comment.