0
0
mirror of https://github.com/django/django.git synced 2024-11-28 21:43:13 +01:00
django/tests/generic_inline_admin/admin.py

Ignoring revisions in .git-blame-ignore-revs. Click here to bypass and see the normal blame view.

32 lines
713 B
Python
Raw Normal View History

from django.contrib import admin
from django.contrib.contenttypes.admin import GenericTabularInline
from .models import Category, Contact, Episode, EpisodePermanent, Media, PhoneNumber
site = admin.AdminSite(name="admin")
class MediaInline(GenericTabularInline):
model = Media
class EpisodeAdmin(admin.ModelAdmin):
inlines = [
MediaInline,
]
class PhoneNumberInline(GenericTabularInline):
model = PhoneNumber
class MediaPermanentInline(GenericTabularInline):
model = Media
can_delete = False
site.register(Episode, EpisodeAdmin)
site.register(Contact, inlines=[PhoneNumberInline])
site.register(Category)
site.register(EpisodePermanent, inlines=[MediaPermanentInline])