django-galleries is a photo gallery app for django that enables you to add/edit/remove images inline with the model that the gallery belongs to in the django admin interface.
JavaScript Python
Switch branches/tags
Nothing to show
Pull request Compare This branch is 7 commits behind espenhogbakk:master.
Fetching latest commit…
Cannot retrieve the latest commit at this time.
Failed to load latest commit information.

Django Galleries


Django Galleries is a photo gallery app that makes it easy to include galleries in your django apps. It has an easy to use, drag & drop interface for managing the photos. It also includes tools for cropping the images.

Example Example edit


Sadly, there is a few things that needs to be configured. I will try to make this list smaller with time, but for now everything is necessary. This is somewhat because I am utilizing a few other apps.

In your settings module add the following:

from easy_thumbnails import defaults
) + defaults.PROCESSORS



Make sure that you have configured your MEDIA_ROOT to handle file uploads. Set it to something like MEDIA_ROOT = os.path.join(PROJECT_PATH, 'media')

And then add this to MIDDLEWARE_CLASSES:


This is requirements from django-respite that 'django-galleries` utilizes.

Then in your file

Add (r'^admin/galleries', include('galleries.urls', namespace='galleries', app_name='galleries')),

If you are in development mode, remember to host your media files accordingly, add something like this

from django.conf import settings
# Serve media files through Django if in debug mode
if settings.DEBUG:
    urlpatterns += patterns('django.views',
        url(r'%s(?P<path>.*)$' % settings.MEDIA_URL[1:], "static.serve", {
            'document_root': settings.MEDIA_ROOT

At the moment, all images in a gallery has to use the same aspect ratio, it defaults to 16/9, but you can override that with the setting GALLERIES_IMAGE_CROPPING_RATIO:


And at last, remember to do a syncdb to update the database.


Add the GalleryForeignKey to your file, e.g:

from galleries.fields import GalleryForeignKey

class Article(models.Model):
    title = models.CharField(max_length=255)
    gallery = GalleryForeignKey('galleries.Gallery', blank=True, null=True, on_delete=models.SET_NULL)

    def __unicode__(self):
        return self.title

This is just a regular models.ForeignKey except that is has a default widget that adds all the javascript and styling that makes everything work. You could of course if you wanted to, not use the GalleryForeignKey, but override the widget on a regular ForeignKey, if so, use galleries.widgets.GalleryForeignKeyWidget.

And then in you're template you can do something like this:

{% if %}
<div id="gallery">
    {% for image in %}
    <li><img src="{% thumbnail image.image 610x343 box=image.cropping crop detail %}" alt="" /></li>
    {% endfor %}
{% endif %}