django-image-sitemaps

Google Image Sitemaps builder for Django
Download

django-image-sitemaps Ranking & Summary

Advertisement

  • Rating:
  • License:
  • BSD License
  • Price:
  • FREE
  • Publisher Name:
  • Francois Vantomme
  • Publisher web site:
  • https://github.com/akarzim/

django-image-sitemaps Tags


django-image-sitemaps Description

django-image-sitemaps is an app that provides Google image sitemaps for Django. More informations about image sitemaps on Google Webmaster Tools.InstallationYou can get image-sitemaps from pypi with:pip install django-image-sitemapsThe development version can be installed with:pip install -e git://github.com/akarzim/image-sitemaps#egg=image-sitemapsimage-sitemaps introduce a new XML template therefore you should add it to your INSTALLED_APPS in settings.py:INSTALLED_APPS = ( ... 'imagesitemaps', ...)UsageCreate a new file named sitemaps.py in your app directory and declare your ImageSitemap classes :# -*- coding: utf-8 -*-from django.core.urlresolvers import reverseimport imagesitemapsclass ImageSitemap(imagesitemaps.ImageSitemap): """ generic data for all ours image sitempas (use it as you used to with Django Sitemap) """ changefreq = 'weekly' priority = 0.5 def lastmod(self, obj): return obj.modifiedclass ProductImageSitemap(ImageSitemap): """ a specific image sitemap for ours Product class """ def items(self): """ Django Sitemap's items method """ return Product.objects.all() def images(self, obj): """ this method allows you to define multiple images for an object """ return obj.images() def image_loc(self, img): """ this required method define the image location """ return img.doc.url def image_caption(self, img): """ this optional method define the image caption """ return unicode(img) def location(self, obj): """ Django Sitemap's location method """ return reverse( 'webstore_product', kwargs={ 'slug_product': obj.slug, } )Then you have to add this data at the end of your Django root urls.py :from myapp.sitemaps import ProductImageSitemapimagesitemaps = { 'products': ProductImageSitemap,}urlpatterns += patterns('imagesitemaps.views', url(r'^sitemap-image\.xml$', 'index', {'sitemaps': imagesitemaps}), url(r'^sitemap-image-(?P< section >.+)\.xml$', 'sitemap', {'sitemaps': imagesitemaps}),)Product's homepage


django-image-sitemaps Related Software