Add Django admin site

This commit is contained in:
Tanner Collin 2021-03-20 17:11:47 -06:00
parent 5d7103081c
commit 56d3a1a862
2 changed files with 11 additions and 1 deletions

View File

@ -1,3 +1,10 @@
from django.apps import apps
from django.contrib import admin 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

View File

@ -1,3 +1,5 @@
from django.conf.urls import url
from django.contrib import admin
from django.urls import include, path from django.urls import include, path
from rest_framework import routers from rest_framework import routers
from .api import views from .api import views
@ -7,6 +9,7 @@ router.register(r'users', views.UserViewSet)
urlpatterns = [ urlpatterns = [
path('', include(router.urls)), path('', include(router.urls)),
path('admin/', admin.site.urls),
path('api-auth/', include('rest_framework.urls', namespace='rest_framework')), path('api-auth/', include('rest_framework.urls', namespace='rest_framework')),
url(r'^rest-auth/', include('rest_auth.urls')), url(r'^rest-auth/', include('rest_auth.urls')),
url(r'^rest-auth/registration/', include('rest_auth.registration.urls')), url(r'^rest-auth/registration/', include('rest_auth.registration.urls')),