Skip to main content

Reusable multiple file upload for Django admin in new UI style. Compatible with Django's default admin, Jazzmin, and Grappelli admin interfaces.

Project description

PyPI Downloads

django-admin-multiupload

Reusable multiple file upload for Django admin in new UI style. Compatible with Django's default admin, Jazzmin, and Grappelli admin interfaces. Install the package and use the mixins in your admin classes — the templates, CSS, and JS are bundled so you do not have to wire up static files manually.

Examples

Default Django Admin

Django Default Admin

Jazzmin Theme

Jazzmin Theme

Grappelli Theme

Grappelli Theme

Installation

# with uv
uv add django-admin-multiupload

# or pip
pip install django-admin-multiupload

Add the app to INSTALLED_APPS so Django can discover the bundled templates and static assets:

INSTALLED_APPS = [
    # ...
    "django_admin_multiupload",
]

Usage

models.py

from django.db import models


class Product(models.Model):
    name = models.CharField(max_length=255)
    description = models.TextField()
    price = models.DecimalField(max_digits=10, decimal_places=2)

    def __str__(self):
        return self.name


class ProductImage(models.Model):
    product = models.ForeignKey(
        Product, on_delete=models.CASCADE, related_name="images"
    )
    image = models.ImageField(upload_to="product_images")

    def __str__(self):
        return self.product.name


class ProductFile(models.Model):
    product = models.ForeignKey(Product, on_delete=models.CASCADE, related_name="files")
    file = models.FileField(upload_to="product_files")

    def __str__(self):
        return self.product.name

admin.py

from django.contrib import admin

from django_admin_multiupload import MultipleUploadAdminMixin, MultipleUploadInlineMixin
from .models import Product, ProductFile, ProductImage


class ProductImageInline(MultipleUploadInlineMixin, admin.TabularInline):
    model = ProductImage
    extra = 1
    upload_field_name = "image"


class ProductFileInline(MultipleUploadInlineMixin, admin.TabularInline):
    model = ProductFile
    extra = 1
    upload_field_name = "file"


@admin.register(Product)
class ProductAdmin(MultipleUploadAdminMixin, admin.ModelAdmin):
    list_display = ("name", "price")
    search_fields = ("name", "description")
    inlines = [ProductImageInline, ProductFileInline]

That is it. The admin change form will render the drag-and-drop upload area and load the package's CSS/JS automatically.

How It Works

  1. Add MultipleUploadInlineMixin to your inline class and specify upload_field_name
  2. Add MultipleUploadAdminMixin to your ModelAdmin class that uses the inline
  3. The mixin automatically detects if the field is an ImageField or FileField
  4. Files are uploaded and saved automatically when you save the parent object

License

MIT License - see LICENSE file for details.

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_admin_multiupload-0.1.2.tar.gz (23.1 kB view details)

Uploaded Source

Built Distribution

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

django_admin_multiupload-0.1.2-py3-none-any.whl (81.9 kB view details)

Uploaded Python 3

File details

Details for the file django_admin_multiupload-0.1.2.tar.gz.

File metadata

File hashes

Hashes for django_admin_multiupload-0.1.2.tar.gz
Algorithm Hash digest
SHA256 54da2ca5d610d03f04d71ca1061f4ecac0249d010bfcf7b21c55c7bbdcfb2de5
MD5 204cdeec267e8c7c4b5f823cd0c2c92b
BLAKE2b-256 f8a40526822b42161b6be0d6e77b46612119eeb045f98d73b56d04331532c356

See more details on using hashes here.

File details

Details for the file django_admin_multiupload-0.1.2-py3-none-any.whl.

File metadata

File hashes

Hashes for django_admin_multiupload-0.1.2-py3-none-any.whl
Algorithm Hash digest
SHA256 9d58cd8f7a692c2b40be4a27ba6196a44081e7002c69fd4e388262b257f01d62
MD5 06bdc90bc7fbf8ff7baebcf90b6c0194
BLAKE2b-256 566dbbd1738446881ae17f221c010fcd545378aaec32d1879b43f8af834e571d

See more details on using hashes here.

Supported by

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