Skip to content
Django Image Field Example
Branch: master
Clone or download
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Type Name Latest commit message Commit time
Failed to load latest commit information.

ImageField Sample Application

This an implementation of a tiny image gallery site with single Django application "gallery".

It is meant as an example for my blog post: Django Image and File Field Caveats

Setup and Run

python3 -m venv venv             # Create new virtual environment
. venv/bin/activate              # Activate the new environment
pip install -r requirements.txt  # Install required packages
cd apps
./ migrate              # Create DB tables
./ runserver            # Run development server

You can access the gallery application on the following URL: http://localhost:8000/

Gallery application

Most of the code exists under "apps/gallery", including the model, views, url routing (, and templates. changes

Changes in "apps/apps/":

MEDIA_URL = '/media/'
MEDIA_ROOT = os.path.join(BASE_DIR, '..','www','media') changes

from django.conf import settings
from django.conf.urls.static import static
if settings.DEBUG:
    urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
You can’t perform that action at this time.