I would suggest to have a similar attribute on the database field itself,
as well as on the form field and widget.
The major point for discussion would be how to store the data. The easiest
would be to coma separate the paths in a single char field. The major
concern here would be the lack of atomicity. For databases like Postgres I
would be sensical to use the `ArrayField` as an underlying structure.
Another way for serialisation would be the use of JSONs in a char field.
All solutions based on a text or char field have an issue related to the
compatibility with the current `FileField` which is limited to 100
characters. The type would need to be migrated to a text type or the
length would need to be increased. The latter options bares the question
to which point.
Another approach would be to defer the storage issue and only provide
support for multiple files on form level.
This would mean to add a `multiple` attribute to the form field and
widget. Users would be able to create forms with multiple files in a
single field and handle storage according to their preference.
--
Ticket URL: <https://code.djangoproject.com/ticket/28554>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.
* owner: nobody => Johannes Hoppe
* status: new => assigned
--
Ticket URL: <https://code.djangoproject.com/ticket/28554#comment:1>
Comment (by Johannes Hoppe):
I tried to exclude my personal opinion and preference from the ticket
description, to have an open discussion.
So here goes my personal opinion:
It seems odd to me that the `FileField` is limited to 100 characters. I
could not find any reference to why the field was limited in the first
place. Furthermore I do not know of any file system with a 100 char
limitation nor are URLs limited to only 100 chars.
Therefore I would suggest basing the `FileField` upon the `TextField`.
I would recommend splitting the issue tho. I would first add support form
multiple files to form. This is a nice feature in itself and requires
little work and good documentation. I would presume that such a feature
would spawn a larger discussion on how to store those files. As multiple
model instances? As an Array in Postgres? As CSV or JSON in a `TextField`?
I think we can figure this out later or not at all if we don't come to a
conclusion.
I would love to work on that. I do maintain [django-
s3file](https://github.com/codingjoe/django-s3file/) and [django-
stdimage](https://github.com/codingjoe/django-stdimage/) and have some
experience with custom the `FileInput` and `FileField`. Let me know if I
can be of any help.
Cheers
-joe
--
Ticket URL: <https://code.djangoproject.com/ticket/28554#comment:2>
* version: 1.11 => master
* stage: Unreviewed => Accepted
Comment:
+1 to adding `multiple` at the form layer.
About storage, I'm not sure we'll find a common enough use case to
implement a storage strategy in Django itself. I guess that second part
warrants a discussion on django-developers.
--
Ticket URL: <https://code.djangoproject.com/ticket/28554#comment:3>
* needs_better_patch: 0 => 1
* has_patch: 0 => 1
* needs_tests: 0 => 1
* needs_docs: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/28554#comment:4>
* needs_better_patch: 1 => 0
* needs_tests: 1 => 0
* needs_docs: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/28554#comment:5>
Comment (by Thomas Güttler):
Just for the records, this lib tries to solve this:
https://github.com/Chive/django-multiupload
{{{
Django Multiupload
Build Status
Dead simple drop-in multi file upload field for django forms using HTML5's
multiple attribute.
}}}
--
Ticket URL: <https://code.djangoproject.com/ticket/28554#comment:6>
Comment (by Johannes Hoppe):
Thanks Thomas, I took a look at the package. It does a lot more than what
I want to implement here. Still it would make sense to add basic support
to Django.
--
Ticket URL: <https://code.djangoproject.com/ticket/28554#comment:7>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/28554#comment:8>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/28554#comment:9>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/28554#comment:10>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/28554#comment:11>
* needs_better_patch: 0 => 1
--
Ticket URL: <https://code.djangoproject.com/ticket/28554#comment:12>
* needs_better_patch: 1 => 0
--
Ticket URL: <https://code.djangoproject.com/ticket/28554#comment:13>