我有下面的“RecordEntry”模式简单投稿页面的应用程序:我需要一个小部件来浏览文件系统
class RecordEntry(models.Model):
client = models.ForeignKey(PostPage)
filename = models.CharField(max_length=64, unique=False, blank=True, null=True)
descriptor = models.CharField(max_length=64, unique=False, blank=True, null=True)
date = models.DateField(_("Date"), default=datetime.date.today)
post_type = models.CharField(max_length=50, choices=POST_CHOICES)
round = models.CharField(max_length=50, choices=ROUND_CHOICES)
pdf = models.CharField(max_length=100, unique=False, blank=True, null=True)
html = models.CharField(max_length=100, unique=False, blank=True, null=True)
zip = models.CharField(max_length=100, unique=False, blank=True, null=True)
psd = models.CharField(max_length=100, unique=False, blank=True, null=True)
def __unicode__ (self):
return return u'%s %s' % (self.client, self.filename)
class Admin:
pass
的PDF,HTML,ZIP和PSD领域将保持路径对这些对象的哪些将作为模板的链接显示。我的问题是,是否有办法避免每次都在这些字段中输入整个路径?是否有某种类型的窗口小部件可以让我浏览文件系统并捕获单击的任何项目的路径?
为什么不直接使用FileField? https://docs.djangoproject.com/en/1.3/ref/models/fields/#filefield – Brandon
我可能会误解,但我认为FileField实际上已将文件上传到设置中指定的媒体目录。我只想引用已经存在于服务器上的文件的路径。 FileField可能允许我这样做(我正在研究它),我只是假设它不能。 – kjarsenal
是的,它也处理上传。要浏览目录,请尝试使用FilePathField:https://docs.djangoproject.com/en/1.3/ref/models/fields/#filepathfield – Brandon