From fa0c4e0fa9ea3ade64deeff053a584fb4d119052 Mon Sep 17 00:00:00 2001 From: "Bc. Petr Pecha" Date: Tue, 23 Jun 2015 10:50:58 +0200 Subject: [PATCH] Novinky | vytvoreni modelu --- seminar/models.py | 19 +++++++++++++++++++ 1 file changed, 19 insertions(+) diff --git a/seminar/models.py b/seminar/models.py index 6f43d225..6c2c99cb 100644 --- a/seminar/models.py +++ b/seminar/models.py @@ -618,3 +618,22 @@ class Nastaveni(SingletonModel): def verejne(self): return False + + +@python_2_unicode_compatible +class Novinky(models.Model): + datum = models.DateField(auto_now_add=True) + text = models.TextField('Text novinky', blank=True, null=True) + obrazek = models.ImageField('Obrázek', upload_to='image_novinky/%Y/%m/%d/', + null=True, blank=True) + autor = models.ForeignKey(settings.AUTH_USER_MODEL, + verbose_name='Autor novinky') + zverejneno = models.BooleanField('Zveřejněno', default="False") + + def __str__(self): + return '[' + self.datum + '] ' + self.text[0:20] + + class Meta: + verbose_name = 'Novinka' + verbose_name_plural = 'Novinky' +