July 2018
Intermediate to advanced
324 pages
8h 14m
English
Integrating models with the Django admin panel requires enabling the admin URL configurations in the root urls.py file. Let's have a look at the code:
File—imageGalleryProject/urls.py:
from django.contrib import adminfrom django.urls import pathurlpatterns = [ path('admin/', admin.site.urls),]
Admin configuration is based on the Django application, so we have to configure the admin under the gallery app. The following is the code snippet of the gallery app's admin.py file:
File—gallery/admin.py:
from django.contrib import adminfrom django.utils.html import mark_safefrom gallery.models import PhotoAlbum, Photo# Register your models here.class PhotoAdminInline(admin.TabularInline): model = Photo extra = 1 fields ...
Read now
Unlock full access