5👍
Currently, I think the django.contrib.postgres.fields.ArrayField
is in active development. The django.contrib
package is new to django 1.8 (which is still in beta) so I think this functionality is too early to count on.
The text field you are seeing is meant to be a delimited string which is saved in the array. It kinda makes sense with an array of FileFields
because the FileField
saves a URL string and not a blob of the file (as far as I can tell).
A \d table
gives the table information on that column as follows:
arrayexample=# \d example_post
Column | Type | Modifiers
--------------------------------------------------
attachments | character varying(100)[] |
Currently the field you are seeing in admin is created from here. Notice it inherits from forms.CharField
while a FileField
uses forms.ClearableFileInput.
I don’t think the functionality you are looking for currently exists in Django but I think it is feasible to build it. Personally, I would approach building it by subclassing the existing ArrayField
and overriding the formfield to use my custom form_class
to better handle an Array
of FileField
s.
I hope this helps, I also don’t see any open pull requests for this feature.
0👍
You should use FileField.storage which handles the storage and retrieval of files. For more details, refer Django’s documentation on Managing Files
- Django – Media upload [Errno 13] Permission denied
- Making Django development server faster at serving static media
- How to throttle Django error emails
- Django haystack EdgeNgramField given different results than elasticsearch
- Object is not subscriptable using django and python