diff --git a/server/server/api/admin.py b/server/server/api/admin.py index 8c38f3f..db4e876 100644 --- a/server/server/api/admin.py +++ b/server/server/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 diff --git a/server/server/urls.py b/server/server/urls.py index 11cdcd0..1f72d34 100644 --- a/server/server/urls.py +++ b/server/server/urls.py @@ -1,3 +1,5 @@ +from django.conf.urls import url +from django.contrib import admin from django.urls import include, path from rest_framework import routers from .api import views @@ -7,6 +9,7 @@ router.register(r'users', views.UserViewSet) urlpatterns = [ path('', include(router.urls)), + path('admin/', admin.site.urls), path('api-auth/', include('rest_framework.urls', namespace='rest_framework')), url(r'^rest-auth/', include('rest_auth.urls')), url(r'^rest-auth/registration/', include('rest_auth.registration.urls')),