Skip to content

Commit

Permalink
automatically adding admin view for model not registered yet in ifbca…
Browse files Browse the repository at this point in the history
…tsandbox_api application
  • Loading branch information
bryan-brancotte committed Jul 23, 2020
1 parent d7659ce commit 351543e
Showing 1 changed file with 11 additions and 0 deletions.
11 changes: 11 additions & 0 deletions ifbcatsandbox_api/admin.py
Original file line number Diff line number Diff line change
Expand Up @@ -213,3 +213,14 @@ class TrainingMaterialAdmin(ViewInApiModelAdmin):
'audienceRoles',
'license',
)


# register all models that are not registered yet
from django.apps import apps

models = apps.get_app_config('ifbcatsandbox_api').get_models()
for model in models:
try:
admin.site.register(model)
except admin.sites.AlreadyRegistered:
pass

0 comments on commit 351543e

Please sign in to comment.