Upload images to Django

Asked

Viewed 501 times

1

How to upload more than 1 image in Django Admin ? this is my mode :

    from django.db import models

class Imovel(models.Model):
    titulo = models.CharField('Titulo', max_length=200, blank=False)
    slug = models.SlugField('Slug')
    cep = models.IntegerField('CEP', blank=False)
    estado = models.CharField('Estado', max_length=50, blank=False)
    cidade = models.CharField('Cidade', max_length=50, blank=False)
    bairro = models.CharField('Bairro', max_length=200, blank=False)
    endereco = models.CharField('Endereço', max_length=300, blank=False)
    telefone = models.IntegerField('Telefone')
    descricao = models.TextField('Descrição')
    tipo = models.CharField('Tipo', max_length=20)
    quartos = models.IntegerField('Quartos')
    vaga_garagem = models.IntegerField('Vagas na Garagem')
    fotos = models.ImageField('Fotos',
                              upload_to='imagens/%Y/')


    def __str__(self):
        return self.titulo
  • You can create another table and set a relation one for many. Have knowledge about relational databases?

No answers

Browser other questions tagged

You are not signed in. Login or sign up in order to post.