Render html file in template in django

0

I have a class in Django that models a Post and would like to allow a user to upload a file but how do I render that file in the django template ???

class Article(DateAbstractModel):

    'Modelo de um artigo do site'

    name = models.CharField(verbose_name = 'Nome', max_length = 100)
    slug = models.SlugField(verbose_name = 'Atalho', max_length = 120)
    confirmed = models.BooleanField(verbose_name = 'Confirmado', default = False, blank = True)
    description = models.CharField(verbose_name = 'Descrição', max_length = 200)
    file = models.FileField(
        verbose_name = 'Arquivo',
        upload_to = 'files/articles/',
        null = False,
        blank = False
    )

    user = models.ForeignKey(
        User,
        on_delete = models.CASCADE,
        related_name = 'articles'
    )

    tags = models.ManyToManyField(Tag)

    objects = ArticleManager()

    def __str__(self):
        return self.name

    def get_absolute_url(self):
        return reverse('articles:article', args = (self.slug, ))

    def date(self):
        return reverse('articles:articles_date', args = (self.created_at.month, self.created_at.year))


    class Meta:
        verbose_name = 'Artigo'
        verbose_name_plural = 'Artigos'
        ordering = ['-created_at']
    
asked by anonymous 26.05.2018 / 03:20

0 answers