如何使用Django将多个文件上传到PostgreSQL数据库?
答案 0 :(得分:1)
如何使用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