Skip to main content

Django Multiupload

Build Status

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)
$ pip install django-multiupload
  • Or directly from this repository to get the development version (if you're feeling adventurous)
$ 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.

# forms.py
from django import forms
from multiupload.fields import MultiFileField, MultiMediaField, MultiImageField

class UploadForm(forms.Form):
    attachments = MultiFileField(min_num=1, max_num=3, max_file_size=1024*1024*5)

    # If you need to upload media files, you can use this:
    attachments = MultiMediaField(
        min_num=1,
        max_num=3,
        max_file_size=1024*1024*5,
        media_type='video'  # 'audio', 'video' or 'image'
    )

    # For images (requires Pillow for validation):
    attachments = MultiImageField(min_num=1, max_num=3, max_file_size=1024*1024*5)

The latter two options just add fancy attributes to HTML's <input>, restricting the scope to corresponding filetypes.

# models.py
from django.db import models

class Attachment(models.Model):
    file = models.FileField(upload_to='attachments')
# 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)

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.6.1.tar.gz (6.2 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_multiupload-0.6.1-py3-none-any.whl (7.4 kB view details)

Uploaded Python 3

File details

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

File metadata

  • Download URL: django-multiupload-0.6.1.tar.gz
  • Upload date:
  • Size: 6.2 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for django-multiupload-0.6.1.tar.gz
Algorithm Hash digest
SHA256 85ee24db8fdb1082494daea312fed5649ecab07326f8502ccf58ca6ab2e3fe5d
MD5 dbdf86cfeee407f529b3cf5bcd5a90e6
BLAKE2b-256 6726aeac3095539b591f4dde37c979129c3dccd84c9071f55074ce3c8b99d970

See more details on using hashes here.

File details

Details for the file django_multiupload-0.6.1-py3-none-any.whl.

File metadata

  • Download URL: django_multiupload-0.6.1-py3-none-any.whl
  • Upload date:
  • Size: 7.4 kB
  • Tags: Python 3
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/3.4.2 importlib_metadata/4.8.1 pkginfo/1.7.1 requests/2.26.0 requests-toolbelt/0.9.1 tqdm/4.62.3 CPython/3.10.0

File hashes

Hashes for django_multiupload-0.6.1-py3-none-any.whl
Algorithm Hash digest
SHA256 ac968fdce7f2640531acbcc003bf1d41ab122bf72a6972ef02940885f0cea2d5
MD5 460f68f7f9692da0e66ffe5bb08e2566
BLAKE2b-256 180d644af993262efe2fa846beb21707d4a781b2649171f3ee4448079ba8b7de

See more details on using hashes here.

Release history Release notifications | RSS feed

This release

0.6.1 This release

2 files

0.5.2

2 files

0.5.1

2 files

0.5

1 file

0.3

2 files

0.2

2 files

0.1

1 file

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page