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)

Metadata

Release files for django-multiupload2 0.5.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-multiupload2 0.5.3
File Size Uploaded
django-multiupload2-0.5.3.tar.gz 5.3 kB Details

Release files / django-multiupload2-0.5.3.tar.gz

Download URL django-multiupload2-0.5.3.tar.gz
Size 5.3 kB
Tags Source
SHA-256 checksum
How to use checksums
d14a9859ab671b8815f5e759b5d14681b990530bc96c7dc50be2e0cee87ed6e4
BLAKE2b-256 checksum
How to use checksums
68ae8bd9fb5e202d96818de832c6bba207345d21c94bed68cd1e15a52f2ec65e
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No
Uploaded via twine/3.1.1 pkginfo/1.5.0.1 requests/2.22.0 setuptools/42.0.2 requests-toolbelt/0.9.1 tqdm/4.41.1 CPython/3.6.9

Release history Release notifications | RSS feed

This release

0.5.3 This release

1 release file

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page