0

How to upload multiple files with Django into a PostgreSQL database?

1
  • 1
    what did you try? googling is not enough Commented Dec 10, 2016 at 1:02

1 Answer 1

2

One of the way how to do it is to use ForeignKey:

class Album(models.Model):
  name = models.CharField(max_length=50)
  description = models.TextField(max_length=10000, blank=True)

class Images(models.Model):

  image = models.ImageField(u upload_to='images/', blank=True)
  album = models.ForeignKey('Album', blank=True, null=True)

  def __unicode__(self):
    return self.image.name
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.