【问题标题】:How to upload multiple files with Django into a PostgreSQL database?如何使用 Django 将多个文件上传到 PostgreSQL 数据库中?
【发布时间】:2017-04-25 13:28:31
【问题描述】:

如何使用 Django 将多个文件上传到 PostgreSQL 数据库中?

【问题讨论】:

  • 你尝试了什么?谷歌搜索是不够的

标签: python django postgresql file upload


【解决方案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

【讨论】:

    猜你喜欢
    • 2014-05-24
    • 1970-01-01
    • 2013-06-06
    • 1970-01-01
    • 2013-09-29
    • 2022-08-06
    • 1970-01-01
    • 2022-11-10
    • 1970-01-01
    相关资源
    最近更新 更多