【发布时间】:2017-04-25 13:28:31
【问题描述】:
如何使用 Django 将多个文件上传到 PostgreSQL 数据库中?
【问题讨论】:
-
你尝试了什么?谷歌搜索是不够的
标签: python django postgresql file upload
如何使用 Django 将多个文件上传到 PostgreSQL 数据库中?
【问题讨论】:
标签: python django postgresql file upload
其中一种方法是使用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
【讨论】: