Dead simple drop-in multi file upload field for django forms using HTML5's multiple attribute.
Project description
# Django Multiupload
Dead simple drop-in multi file upload field for django forms using HTML5's ``multiple`` attribute.
## Installation
* Install the package using pip (or easy_install if you really have to)
```bash
$ pip install django-multiupload
```
* or directly from this repository the get the development version (if you're feeling adventurous)
```bash
$ pip install -e git+https://github.com/Chive/django-multiupload.git#egg=multiupload
```
Usage
-----
Add the form field to your form and make sure to save the uploaded files in the form's ``save`` method.
For more detailed examples visit the [examples section](https://github.com/Chive/django-multiupload/tree/master/examples)
```python
# forms.py
from django import forms
from multiupload.fields import MultiFileField
class UploadForm(forms.Form):
attachments = MultiFileField(min_num=1, max_num=3, max_file_size=1024*1024*5)
```
```python
# models.py
from django.db import models
class Attachment(models.Model):
file = models.FileField(upload_to='attachments')
```
```python
# views.py
from django.views.generic.edit import FormView
from .forms import UploadForm
from .models import Attachment
class UploadView(FormView):
template_name = 'form.html'
form_class = UploadForm
success_url = '/done/'
def form_valid(self, form):
for each in form.cleaned_data['attachments']:
Attachment.objects.create(file=each)
return super(UploadView, self).form_valid(form)
```
Dead simple drop-in multi file upload field for django forms using HTML5's ``multiple`` attribute.
## Installation
* Install the package using pip (or easy_install if you really have to)
```bash
$ pip install django-multiupload
```
* or directly from this repository the get the development version (if you're feeling adventurous)
```bash
$ pip install -e git+https://github.com/Chive/django-multiupload.git#egg=multiupload
```
Usage
-----
Add the form field to your form and make sure to save the uploaded files in the form's ``save`` method.
For more detailed examples visit the [examples section](https://github.com/Chive/django-multiupload/tree/master/examples)
```python
# forms.py
from django import forms
from multiupload.fields import MultiFileField
class UploadForm(forms.Form):
attachments = MultiFileField(min_num=1, max_num=3, max_file_size=1024*1024*5)
```
```python
# models.py
from django.db import models
class Attachment(models.Model):
file = models.FileField(upload_to='attachments')
```
```python
# views.py
from django.views.generic.edit import FormView
from .forms import UploadForm
from .models import Attachment
class UploadView(FormView):
template_name = 'form.html'
form_class = UploadForm
success_url = '/done/'
def form_valid(self, form):
for each in form.cleaned_data['attachments']:
Attachment.objects.create(file=each)
return super(UploadView, self).form_valid(form)
```
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
File details
Details for the file django-multiupload-0.5.1.tar.gz
.
File metadata
- Download URL: django-multiupload-0.5.1.tar.gz
- Upload date:
- Size: 4.3 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 68a619593d1a32f31f6fe9057daad6c5cdc55d8844264b204b4d2d4e7c1913eb |
|
MD5 | fe2468c77e897e7ae896c5fc726e0055 |
|
BLAKE2b-256 | bcd8a38aeb31dad898483b929ebf1c20009024804a5af69caa11e97d056bdcb0 |
File details
Details for the file django_multiupload-0.5.1-py2-none-any.whl
.
File metadata
- Download URL: django_multiupload-0.5.1-py2-none-any.whl
- Upload date:
- Size: 6.1 kB
- Tags: Python 2
- Uploaded using Trusted Publishing? No
File hashes
Algorithm | Hash digest | |
---|---|---|
SHA256 | 6ad0a6e605a30e09bc7864cd0f0052436da67e71132feb951d6ba6b86c4055b0 |
|
MD5 | afa445b14a83df06fbc9ad5e3f9f69ad |
|
BLAKE2b-256 | 441631aca825b2e0a188cf0923384204ff500982d1633db5464b2858bf593b3e |