Dead simple drop-in multi file upload field for django forms using HTML5's multiple attribute.
Project description
Django Multiupload Plus ⏩
🍴 This is a forked and updated version based on original library django-multiupload.
As for 31.12.2024 nobody took responsibility, so I decided to take it since we need that fix in one of our project.
Dead simple drop-in multi file upload field for django forms using HTML5's multiple attribute.
To keep Django ecosystem fresh and updated, please share your love and support, click Star 🫶
Installation
- Install the package using
pip
$ pip install django-multiupload-plus
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_plus.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().form_valid(form)
Project details
Release history Release notifications | RSS feed
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
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_multiupload_plus-0.1.0.tar.gz.
File metadata
- Download URL: django_multiupload_plus-0.1.0.tar.gz
- Upload date:
- Size: 6.6 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
83cf0e95b17bca5a1d9bc841bf9ecba4ea90b568f164d3fe3617b3db2d3cb34c
|
|
| MD5 |
e7000b230902e89cb8c0b7cda1571afe
|
|
| BLAKE2b-256 |
47f83be82cd59a52af175ba84338f62d1223d2e520bcd85333c99b060c8f1b03
|
File details
Details for the file django_multiupload_plus-0.1.0-py3-none-any.whl.
File metadata
- Download URL: django_multiupload_plus-0.1.0-py3-none-any.whl
- Upload date:
- Size: 7.7 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.0.1 CPython/3.12.4
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
dc85957465810bd4d317ea497dd74219261cca5254a0369e574fb5777cfdc441
|
|
| MD5 |
ae601104914f1804958189bb0bd4936f
|
|
| BLAKE2b-256 |
c9fbf7389346c55a7261b24fd0f2ed2feb6052c9ece02e32b40490742b07da2e
|