Reputation: 11
How to upload multiple files with Django into a PostgreSQL database?
Upvotes: 0
Views: 223
Reputation: 2212
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
Upvotes: 2