https://github.com/inokinoki/django-multiplefilefield
A multiple file field implementation based on django 1.8.18
https://github.com/inokinoki/django-multiplefilefield
Last synced: 5 months ago
JSON representation
A multiple file field implementation based on django 1.8.18
- Host: GitHub
- URL: https://github.com/inokinoki/django-multiplefilefield
- Owner: Inokinoki
- License: mit
- Created: 2018-05-09T15:53:19.000Z (about 8 years ago)
- Default Branch: master
- Last Pushed: 2018-05-10T11:38:59.000Z (about 8 years ago)
- Last Synced: 2025-02-09T08:33:43.894Z (over 1 year ago)
- Language: HTML
- Size: 75.2 KB
- Stars: 1
- Watchers: 3
- Forks: 0
- Open Issues: 5
-
Metadata Files:
- Readme: README.md
- License: LICENSE
Awesome Lists containing this project
README
## Project Description
A multiple file field implementation in Django.
It works well with Django-1.8.18 Python 2.7. Welcome to test it in other version and PR.
[](https://badge.fury.io/py/django-multiplefilefield)
### Installation
- You can install ``django-multiplefilefield`` with a package manage tool which you prefered the most, for example, to me it's pip:
```bash
pip install django-multiplefilefield
```
- Add ``multiplefilefield`` to your ``INSTALLED_APPS`` tuple in your settings file settings*.py:
```python
INSTALLED_APPS = (
# …
"multiplefilefield",
)
```
### Usage
- Fortunately, ``multiplefilefield`` provides the compatibility to the common single file FileField in Django. You can easily change ``models.FileField`` to ``MultipleFileModelField`` , do something to update your old field like:
```bash
./manage.py makemigrations
./manage.py migrate
```
- Or create a new model to have a try with it, just like what I did in the ``multiplefilefield_example`` app:
```python
from django.db import models
from multiplefilefield.fields import MultipleFileModelField
class SimpleMultipleFileFieldModel(models.Model):
hash = models.CharField(name="hash", max_length=128)
files = MultipleFileModelField(name="files")
```
- Once you created a model with ``MultipleFileModelField``, you can use it just like the traditional model with ``FileField``.
### Template
In the template, please do like this (object can be a SimpleMultileFileFieldModel instance)
```html
{% if object.files %}
{% for file in object.files %}
{% endfor %}
{% endif %}
```
### Regular Forms / Admin
In the form, all will be okay. It will be rendered as a ```` with attribute ``multiple`` .
So just ``Command + Click`` to choose multiple files in Mac, ``Ctrl + Click`` in PC. In the smartphones, surely you can choose many files !
### License