From c1e682478baee0fd7a0adbca648fdb890a8ac2b7 Mon Sep 17 00:00:00 2001 From: Tanner Collin Date: Wed, 29 Jan 2020 23:42:44 +0000 Subject: [PATCH] Register all api models with admin page --- apiserver/apiserver/api/admin.py | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/apiserver/apiserver/api/admin.py b/apiserver/apiserver/api/admin.py index 8c38f3f..db4e876 100644 --- a/apiserver/apiserver/api/admin.py +++ b/apiserver/apiserver/api/admin.py @@ -1,3 +1,10 @@ +from django.apps import apps from django.contrib import admin +from django.contrib.admin.sites import AlreadyRegistered -# Register your models here. +app_models = apps.get_app_config('api').get_models() +for model in app_models: + try: + admin.site.register(model) + except AlreadyRegistered: + pass