Created
December 3, 2020 12:49
-
-
Save fandrefh/6b55c622aa6738d78653197615d9394a to your computer and use it in GitHub Desktop.
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
class BannerHome(models.Model): | |
title = models.CharField(verbose_name=_('Título do banner'), max_length=150) | |
description = models.TextField(verbose_name=_('Descrição'), null=True, blank=True, help_text=_('Opcional')) | |
image = models.ImageField(verbose_name=_('Banner'), upload_to='banners/home') | |
class Meta: | |
verbose_name = _('Banner Página Inicial') | |
verbose_name_plural = _('Banners Página Inicial') | |
def __str__(self): | |
return self.title | |
def image_view(self): | |
return mark_safe('<img src="{}" width="400" height="150" />'.format(self.image.url)) | |
image_view.short_description = _('Banner') |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment