From cadc71b1a4c5c9d26e71544942d22b309b2bad20 Mon Sep 17 00:00:00 2001 From: "Bc. Petr Pecha" Date: Sun, 11 Oct 2015 22:13:12 +0200 Subject: [PATCH] galerie | clone + uprava admina Admin se v konecne fazi na toto pouzivat nebude, proto je jen docasny a je velmi ale velmi nepohodlny na tu spoustu a spoustu fotek. --- galerie/admin.py | 18 ++++++++++++++++++ galerie/models.py | 2 +- 2 files changed, 19 insertions(+), 1 deletion(-) create mode 100644 galerie/admin.py diff --git a/galerie/admin.py b/galerie/admin.py new file mode 100644 index 00000000..fc58f14c --- /dev/null +++ b/galerie/admin.py @@ -0,0 +1,18 @@ +from galerie.models import Obrazek, Galerie +from django.contrib import admin +from django.http import HttpResponseRedirect + +class GalerieInline(admin.TabularInline): + model = Obrazek + +class ObrazekAdmin(admin.ModelAdmin): + list_display = ('obrazek_velky', 'nazev', 'popis') + +class GalerieAdmin(admin.ModelAdmin): + model = Galerie + fields = ('zobrazit', 'nazev', 'titulni_obrazek', 'popis', 'galerie_up', 'soustredeni') + list_display = ('nazev', 'datum_zmeny') + inlines = [GalerieInline] + +admin.site.register(Obrazek, ObrazekAdmin) +admin.site.register(Galerie, GalerieAdmin) diff --git a/galerie/models.py b/galerie/models.py index b368415a..e13d50b3 100644 --- a/galerie/models.py +++ b/galerie/models.py @@ -80,7 +80,7 @@ class Galerie(models.Model): datum_vytvoreni = models.DateTimeField('Datum vytvoření', auto_now_add = True) datum_zmeny = models.DateTimeField('Datum poslední změny', auto_now = True) popis = models.TextField('Popis', blank = True, null = True) - titulni_obrazek = models.ForeignKey(Obrazek, blank = False, null = True, related_name = "+", on_delete = models.SET_NULL) + titulni_obrazek = models.ForeignKey(Obrazek, blank = True, null = True, related_name = "+", on_delete = models.SET_NULL) zobrazit = models.IntegerField('Zobrazit?', default = ORG, choices = VIDITELNOST) galerie_up = models.ForeignKey('Galerie', blank = True, null = True) soustredeni = models.ForeignKey(Soustredeni, blank = True, null = True)