1. Artur Barseghyan
  2. django-images-sitemap


Artur Barseghyan (artur.barseghyan@gmail.com)
0.2 Beta. Ready for production.
This package has been discontinued in favour of "django-qartez", which shares the functionality and offers more XML sitemap solutions (images sitemaps, static pages sitemaps, alternate hreflang sitemaps). You are advised to switch to "django-qartez". For users of "django-images-sitemap" the change would be quite trivial and will require minimal efforts. The "django-qartez" package could be found here (https://bitbucket.org/barseghyanartur/django-qartez).

Simple app to generate images sitemap. For more information about images sitemap see the following links:

http://googlewebmastercentral.blogspot.com/2010/04/adding-images-to-your-sitemaps.html http://www.google.com/support/webmasters/bin/answer.py?answer=178636
Install it with pip:
pip install -e hg+http://bitbucket.org/barseghyanartur/django-images-sitemap#egg=images_sitemap

It's pretty much the same as simple Django sitemaps. You may need to add your template directory (where the image_sitemap.xml file is located) to the TEMPLATE_DIRS in the "settings.py".

IMPORTANT! If you supply your images sitemap to the Django sitemaps, it will treat it as simple feed (not image feed). So, make it a separate URL in your "urls.py" and add that URL to the "robots.txt", next to the general sitemap.

IMPORTANT! By default results are cached for 1 hour based on request.path. If your search results are somehow dependant on other criteria, make appropriate changes to the "images_sitemap.xml" template.

IMPORTANT! By default URL of the current site is appended to the "location" (<loc>) and "image_location" (<image:loc>). If you don't want it to happen, override the following variables in your "settings.py" by setting them to False:


from django.conf.urls.defaults import * from images_sitemap import ImagesSitemap

from media.models import Photo from news.models import Article

# Note, that picture_url is a property in your Photo model, which returns an absolute URL to the image file. photo_info_dict = {

'queryset': Photo.objects.all(), 'image_location_field': 'url', 'image_title_field': 'title', 'location_field': 'url', # If your image does not have a detail page, provide just image URL.


article_images_info_dict = {
'queryset': Article.objects.all(), 'image_location_field': 'picture_url',


photos_sitemap = {
'photos': ImagesSitemap(photo_info_dict, priority=0.6),


article_images_sitemap = {
'article_images': ImagesSitemap(article_images_info_dict, priority=0.6),


from ... import photos_sitemap from ... import article_images_sitemap from ... import events_sitemap, articles_sitemap

sitemap = {} sitemap.update(events_sitemap) sitemap.update(articles_sitemap)

urlpatterns = patterns('',

# some generic view using info_dict # ...

# images sitemaps (r'^sitemap-photos-images.xml$', 'images_sitemap.views.render', {'sitemaps': photos_sitemap}) (r'^sitemap-news-images.xml$', 'images_sitemap.views.render', {'sitemaps': article_images_sitemap})

# general sitemaps (r'^sitemap.xml$', 'django.contrib.sitemaps.views.index', {'sitemaps': sitemaps}), (r'^sitemap-(?P<section>.+).xml$', 'django.contrib.sitemaps.views.sitemap', {'sitemaps': sitemaps}),


Sitemap: /sitemap.xml Sitemap: /sitemap-photos-images.xml Sitemap: /sitemap-news-images.xml