7. Photo Gallery

A common feature of many content-driven Web sites is the capability for users to add not only text, but also files—office documents, videos, PDFs, and of course the ubiquitous image. In this example application, we show you a working example of Django’s image upload field—ImageField—as used in a simple gallery-type application. In addition, we make our own custom ImageField subclass capable of automatically generating thumbnails. Finally, we are designing the app with a dynamic root URL to maximize ease of deployment.

The application we are building is simplistic—a collection of generic Items, each of which can have multiple Photo associations, with this small hierarchy represented by a gallery Django project and an items app ...

Get Python Web Development with Django® now with the O’Reilly learning platform.

O’Reilly members experience books, live events, courses curated by job role, and more from O’Reilly and nearly 200 top publishers.