From 65a76935a6a1c56182ed632002d79f7debf75197 Mon Sep 17 00:00:00 2001 From: "Tomas \"Jethro\" Pokorny" Date: Wed, 8 Jan 2020 21:44:50 +0100 Subject: [PATCH] Admin: django-reverse-admin ukazka a fail s m2m. --- requirements.txt | 1 + seminar/admin.py | 33 +++++++++++++++++++++++++++++---- 2 files changed, 30 insertions(+), 4 deletions(-) diff --git a/requirements.txt b/requirements.txt index f2fd4306..22f8e43c 100644 --- a/requirements.txt +++ b/requirements.txt @@ -27,6 +27,7 @@ django-crispy-forms django-imagekit django-polymorphic django-sitetree +django_reverse_admin # Comments akismet==1.0.1 diff --git a/seminar/admin.py b/seminar/admin.py index e524a19d..11944b56 100644 --- a/seminar/admin.py +++ b/seminar/admin.py @@ -1,6 +1,8 @@ from django.contrib import admin from polymorphic.admin import PolymorphicParentModelAdmin, PolymorphicChildModelAdmin, PolymorphicChildModelFilter +from reversion.admin import VersionAdmin +from django_reverse_admin import ReverseModelAdmin # Todo: reversion @@ -9,7 +11,6 @@ import seminar.models as m admin.site.register(m.Osoba) admin.site.register(m.Skola) admin.site.register(m.Prijemce) -admin.site.register(m.Resitel) admin.site.register(m.Rocnik) admin.site.register(m.Cislo) admin.site.register(m.Organizator) @@ -39,11 +40,35 @@ class UlohaAdmin(PolymorphicChildModelAdmin): base_model = m.Uloha show_in_index = True - +class TextAdminInline(admin.TabularInline): + model = m.Text + exclude = ['text_zkraceny_set','text_zkraceny'] admin.site.register(m.Text) -admin.site.register(m.Reseni) -admin.site.register(m.Hodnoceni) + +class ResitelInline(admin.TabularInline): + model = m.Resitel + extra = 1 +admin.site.register(m.Resitel) + +class PrilohaReseniInline(admin.TabularInline): + model = m.PrilohaReseni + extra = 1 admin.site.register(m.PrilohaReseni) + +class Reseni_ResiteleInline(admin.TabularInline): + model = m.Reseni_Resitele + +@admin.register(m.Reseni) +class ReseniAdmin(ReverseModelAdmin): + base_model = m.Reseni + inline_type = 'tabular' + inline_reverse = ['text_cely','resitele'] + exclude = ['text_zkraceny', 'text_zkraceny_set'] + inlines = [PrilohaReseniInline] +# FAIL in template +# inlines = [PrilohaReseniInline,Reseni_ResiteleInline] + +admin.site.register(m.Hodnoceni) admin.site.register(m.Pohadka) admin.site.register(m.Konfera) admin.site.register(m.Obrazek)