Package: django-content-gallery
django-content-gallerydjango-content-galleryis a Django application that allows to attach a collection
of images to objects of any models in you Django projects. It also allows you easily
add and remove images, re-attach images to another object (i.e. move an image to another
collection) and change an order of images in the collection as well.Thedjango-content-gallerycreates 5 images with different sizes for each uploaded image:a large image viewed in the gallery for users with high-resulution displaysa small image viewed in the gallery for users with low-resulution displaysa large preview image used in a previewa small preview image used in a small previewa thumbnail viewed in the list of available imagesRequirementsPython3.4+Django1.10+Pillow3.0.0+python-magic0.4.2+awesome-slugify1.6+django-admin-jqueryui1121.12.1+NoteWindows users should also copymagic1.dll,regex2.dllandzlib1.dllonto
the PATH. These libraries are required by thepython-magicpackage and could be
downloaded on theFile for Windowsofficial page.InstallationTo install thedjango-content-gallerytype following command:$ pip install django-content-galleryThen add thecontent_galleryto INSTALLED_APPS in the settings of your project and theadmin_jqueryuito enable sorting images in the admin panel:INSTALLED_APPS = [
    ...
    'content_gallery',
    'admin_jqueryui',
]Add thecontent_gallery.urlsto the urls.py of your project (you could use any
URL pattern, not only^content_gallery\):urlpatterns = [
    ...
    url(r'^content_gallery/', include('content_gallery.urls')),
]Create tables in the database using themigratecommand:$ python manage.py migrate content_galleryNow thedjango-content-galleryis ready for use!ConfigurationTo change settings of thedjango-content-galleryset theCONTENT_GALLERYdict
in yoursettings.pymodule. The dict could contain following items:image_width- the target width of the large imageimage_height- the target height of the large imagesmall_image_width- the target width of the small imagesmall_image_height- the target height of the small imagethumbnail_width- the target width of the thumbnailthumbnail_height- the target height of the thumbnailpreview_width- the target width of the large previewpreview_height- the target height of the large previewsmall_preview_width- the target width of the small previewsmall_preview_height- the target height of the small previewpath- the subdirectory in theMEDIA_ROOTwhere image files would be storedDefault values of these settings areimage_width= 752image_height= 608small_image_width= 564small_image_height= 456thumbnail_width= 94thumbnail_height= 76preview_width= 376preview_height= 304small_preview_width= 141small_preview_height=114path= ‘content_gallery’You could change some of these settings and keep the rest undefined in yousettings.py,
in this case the default values would be used instead:CONTENT_GALLERY = {
        "image_width": 1024,
        "image_height": 768,
}This code changes size of the large image only, the rest of settings values would be default.UsageTo make your models able to attach a gallery, use theContentGalleryMixinin
models you want to use the content-gallery with:from django.db import models
from content_gallery.models import ContentGalleryMixin

class YourModel(ContentGalleryMixin, models.Model):
    ...Also to be able to edit attached image collection on the admin page of your model,
you need to add theImageAdminInlineto inlines of your model admin. Add following
code to your admin.pyfrom django.contrib import admin
from content_gallery.admin import ImageAdminInline
from . import models

class YourModelAdmin(admin.ModelAdmin):
    inlines = [
        ImageAdminInline,
    ]

admin.site.register(models.YourModel, YourModelAdmin)Now thedjango-content-galleryis available for your models. Then you need to add the
content-gallery to your pages.First of all add thecontent_gallery/_image_view.htmltemplate to your templates where you
want the content-gallery to be available:{% include "content_gallery/_image_view.html" %}Thedjango-content-galleryuses jQuery within its scripts, so make sure that jQuery is
available on your pages where the content-gallery is used.To add the gallery related to your objects onto your pages thedjango-content-galleryprovides
two template tags. Those template tags are located in thecontent_gallerytemplate tag set, so
before use them you should load this set:{% load content_gallery %}The first template tag namedgallery_previewadds the large preview. It uses one argument which
is your object. This tag is meant to be used generally in templates of detail views:{% gallery_preview your_object %}This code adds the preview widget that shows a preview of the first image related to the object.Thegallery_small_previewtag adds a small preview onto the page, it uses such object as an
argument as well, and is meant to be used generally in templates of list views:{% gallery_small_preview your_object %}This code adds the small preview widget that shows a small preview of the first image related
to the object.Also thedjango-content-galleryprovides a simple template tag namedgallery_image_datathat also gets an object as an argument and returns a dict object that contains an object of
the first image and JSON data for constructing a link to the object. You could use this template
tag to construct you own custom widgets.For more details, see thecontent_gallery_testappwhich is an example of
thedjango-content-galleryusage.