Skip to main content

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)

```

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

django-multiupload-0.5.tar.gz (4.1 kB view details)

Uploaded Source

File details

Details for the file django-multiupload-0.5.tar.gz.

File metadata

File hashes

Hashes for django-multiupload-0.5.tar.gz
Algorithm Hash digest
SHA256 ec8d07b44bcf7687cd6cfa0872dd33fe891f868501e57c01e451ae9a508ca501
MD5 4579067b840205b8217b0d692b17cec6
BLAKE2b-256 bbc3b4d1247b7a48f374df2d8de0ca515b132be2a1115f5ab2ec02b83e07131a

See more details on using hashes here.

Supported by

AWS AWS Cloud computing and Security Sponsor Datadog Datadog Monitoring Fastly Fastly CDN Google Google Download Analytics Microsoft Microsoft PSF Sponsor Pingdom Pingdom Monitoring Sentry Sentry Error logging StatusPage StatusPage Status page