GeoDjango has its own Feed subclass that may embed location information in RSS/Atom feeds formatted according to either the Simple GeoRSS or W3C Geo standards. Because GeoDjango’s syndication API is a superset of Django’s, please consult Django’s syndication documentation for details on general usage.
- class Feed¶
In addition to methods provided by the django.contrib.syndication.feeds.Feed base class, GeoDjango’s Feed class provides the following overrides. Note that these overrides may be done in multiple ways:
from django.contrib.gis.feeds import Feed class MyFeed(Feed): # First, as a class attribute. geometry = ... item_geometry = ... # Also a function with no arguments def geometry(self): ... def item_geometry(self): ... # And as a function with a single argument def geometry(self, obj): ... def item_geometry(self, item): ...
Takes the object returned by get_object() and returns the feed's geometry. Typically this is a GEOSGeometry instance, or can be a tuple to represent a point or a box. For example:
class ZipcodeFeed(Feed): def geometry(self, obj): # Can also return: `obj.poly`, and `obj.poly.centroid`. return obj.poly.extent # tuple like: (X0, Y0, X1, Y1).
Set this to return the geometry for each item in the feed. This can be a GEOSGeometry instance, or a tuple that represents a point coordinate or bounding box. For example:
class ZipcodeFeed(Feed): def item_geometry(self, obj): # Returns the polygon. return obj.poly
Having trouble? We'd like to help!
- Try the FAQ — it's got answers to many common questions.
- Search for information in the archives of the django-users mailing list, or post a question.
- Ask a question in the #django IRC channel, or search the IRC logs to see if it has been asked before.
- If you notice errors with this documentation, please open a ticket and let us know! Please only use the ticket tracker for criticisms and improvements on the docs. For tech support, use the resources above.