Skip to main content

Django Image Gallery

An image gallery application for Django projects. Provides an easy way to manage, organize, and display images through the Django admin interface and a reusable template tag.

Features

  • Django model for managing gallery images
  • Automatic resizing of uploaded images exceeding 2000 × 2000 pixels
  • Published and unpublished image management
  • Configurable image ordering
  • Masonry image layout
  • Load-more functionality
  • Full-screen image viewer
  • Django admin integration
  • Reusable template tag

Requirements

  • Python 3.10+
  • Django 5.2, 6.0, or 6.1
  • Pillow 10.0 or later

Installation

Install the package using pip:

pip install django-image-gallery

Configuration

Add django_image_gallery to your project's INSTALLED_APPS:

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

Run the database migrations:

python manage.py migrate

Usage

Load the template tag library and include the gallery wherever you want it displayed:

{% load django_image_gallery %}

{% gallery %}

The template tag retrieves all published gallery images and renders them using the package's included gallery template.

Media Configuration

Configure Django to handle uploaded media files:

MEDIA_URL = "/media/"
MEDIA_ROOT = BASE_DIR / "media"

During local development, you can serve media files through Django by adding the following to your project's root urls.py:

from django.conf import settings
from django.conf.urls.static import static

urlpatterns = [
    # Your URL patterns
]

if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)

For production deployments, configure your web server or storage backend to serve uploaded media files. Uploaded images must be accessible through the configured media storage.

Managing Images

Images can be added and managed through the Django admin interface.

After creating a superuser:

python manage.py createsuperuser

Log in to the admin interface and locate Gallery Images.

Each image supports the following fields:

Field Description
Title Optional image title
Image Uploaded image file
Caption Optional image caption
Sort order Controls the display order of images
Published Determines whether the image appears in the gallery

Only published images appear in the gallery. Images are ordered by sort_order, with newer entries taking precedence when sort orders match.

License

This project is licensed under the MIT License. See the LICENSE file for details.

Metadata

Release files for django-image-gallery 0.1.0

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-image-gallery 0.1.0
File Size Uploaded Provenance Actions
django_image_gallery-0.1.0.tar.gz 19.4 kB Without provenance Details for django_image_gallery-0.1.0.tar.gz

Built distribution (wheel)

Table of built distributions (wheels) for django-image-gallery 0.1.0
File Interpreter ABI Platform Actions
django_image_gallery-0.1.0-py3-none-any.whl Python 3 none any Details for django_image_gallery-0.1.0-py3-none-any.whl

Total release size: 41.1 kB

Security for django-image-gallery 0.1.0

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.1.0 This release

2 release files No provenance

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