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.
This commit is contained in:
Bc. Petr Pecha 2015-10-11 22:13:12 +02:00
parent ef13214718
commit cadc71b1a4
2 changed files with 19 additions and 1 deletions

18
galerie/admin.py Normal file
View file

@ -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)

View file

@ -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)