<!DOCTYPE html PUBLIC "-//W3C//DTD XHTML 1.0 Transitional//EN" "http://www.w3.org/TR/xhtml1/DTD/xhtml1-transitional.dtd"> <html xmlns="http://www.w3.org/1999/xhtml"> <head> <meta http-equiv="Content-Type" content="text/html; charset=utf-8" /> <title>Geographic Feeds — Django 1.5.8 documentation</title> <link rel="stylesheet" href="../../../_static/default.css" type="text/css" /> <link rel="stylesheet" href="../../../_static/pygments.css" type="text/css" /> <script type="text/javascript"> var DOCUMENTATION_OPTIONS = { URL_ROOT: '../../../', VERSION: '1.5.8', COLLAPSE_INDEX: false, FILE_SUFFIX: '.html', HAS_SOURCE: true }; </script> <script type="text/javascript" src="../../../_static/jquery.js"></script> <script type="text/javascript" src="../../../_static/underscore.js"></script> <script type="text/javascript" src="../../../_static/doctools.js"></script> <link rel="top" title="Django 1.5.8 documentation" href="../../../index.html" /> <link rel="up" title="GeoDjango" href="index.html" /> <link rel="next" title="Geographic Sitemaps" href="sitemaps.html" /> <link rel="prev" title="GeoDjango’s admin site" href="admin.html" /> <script type="text/javascript" src="../../../templatebuiltins.js"></script> <script type="text/javascript"> (function($) { if (!django_template_builtins) { // templatebuiltins.js missing, do nothing. return; } $(document).ready(function() { // Hyperlink Django template tags and filters var base = "../../templates/builtins.html"; if (base == "#") { // Special case for builtins.html itself base = ""; } // Tags are keywords, class '.k' $("div.highlight\\-html\\+django span.k").each(function(i, elem) { var tagname = $(elem).text(); if ($.inArray(tagname, django_template_builtins.ttags) != -1) { var fragment = tagname.replace(/_/, '-'); $(elem).html("<a href='" + base + "#" + fragment + "'>" + tagname + "</a>"); } }); // Filters are functions, class '.nf' $("div.highlight\\-html\\+django span.nf").each(function(i, elem) { var filtername = $(elem).text(); if ($.inArray(filtername, django_template_builtins.tfilters) != -1) { var fragment = filtername.replace(/_/, '-'); $(elem).html("<a href='" + base + "#" + fragment + "'>" + filtername + "</a>"); } }); }); })(jQuery); </script> </head> <body> <div class="document"> <div id="custom-doc" class="yui-t6"> <div id="hd"> <h1><a href="../../../index.html">Django 1.5.8 documentation</a></h1> <div id="global-nav"> <a title="Home page" href="../../../index.html">Home</a> | <a title="Table of contents" href="../../../contents.html">Table of contents</a> | <a title="Global index" href="../../../genindex.html">Index</a> | <a title="Module index" href="../../../py-modindex.html">Modules</a> </div> <div class="nav"> « <a href="admin.html" title="GeoDjango&#8217;s admin site">previous</a> | <a href="../../index.html" title="API Reference" accesskey="U">up</a> | <a href="sitemaps.html" title="Geographic Sitemaps">next</a> »</div> </div> <div id="bd"> <div id="yui-main"> <div class="yui-b"> <div class="yui-g" id="ref-contrib-gis-feeds"> <div class="section" id="s-module-django.contrib.gis.feeds"> <span id="s-geographic-feeds"></span><span id="module-django.contrib.gis.feeds"></span><span id="geographic-feeds"></span><h1>Geographic Feeds<a class="headerlink" href="#module-django.contrib.gis.feeds" title="Permalink to this headline">¶</a></h1> <p>GeoDjango has its own <a class="reference internal" href="#django.contrib.gis.feeds.Feed" title="django.contrib.gis.feeds.Feed"><tt class="xref py py-class docutils literal"><span class="pre">Feed</span></tt></a> subclass that may embed location information in RSS/Atom feeds formatted according to either the <a class="reference external" href="http://georss.org/1.0#simple">Simple GeoRSS</a> or <a class="reference external" href="http://www.w3.org/2003/01/geo/">W3C Geo</a> standards. Because GeoDjango’s syndication API is a superset of Django’s, please consult <a class="reference internal" href="../syndication.html"><em>Django’s syndication documentation</em></a> for details on general usage.</p> <div class="section" id="s-example"> <span id="example"></span><h2>Example<a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h2> </div> <div class="section" id="s-api-reference"> <span id="api-reference"></span><h2>API Reference<a class="headerlink" href="#api-reference" title="Permalink to this headline">¶</a></h2> <div class="section" id="s-feed-subclass"> <span id="feed-subclass"></span><h3><tt class="docutils literal"><span class="pre">Feed</span></tt> Subclass<a class="headerlink" href="#feed-subclass" title="Permalink to this headline">¶</a></h3> <dl class="class"> <dt id="django.contrib.gis.feeds.Feed"> <em class="property">class </em><tt class="descname">Feed</tt><a class="headerlink" href="#django.contrib.gis.feeds.Feed" title="Permalink to this definition">¶</a></dt> <dd><p>In addition to methods provided by the <a class="reference internal" href="../syndication.html#django.contrib.syndication.views.Feed" title="django.contrib.syndication.views.Feed"><tt class="xref py py-class docutils literal"><span class="pre">django.contrib.syndication.views.Feed</span></tt></a> base class, GeoDjango’s <tt class="docutils literal"><span class="pre">Feed</span></tt> class provides the following overrides. Note that these overrides may be done in multiple ways:</p> <div class="highlight-python"><div class="highlight"><pre><span class="kn">from</span> <span class="nn">django.contrib.gis.feeds</span> <span class="kn">import</span> <span class="n">Feed</span> <span class="k">class</span> <span class="nc">MyFeed</span><span class="p">(</span><span class="n">Feed</span><span class="p">):</span> <span class="c"># First, as a class attribute.</span> <span class="n">geometry</span> <span class="o">=</span> <span class="o">...</span> <span class="n">item_geometry</span> <span class="o">=</span> <span class="o">...</span> <span class="c"># Also a function with no arguments</span> <span class="k">def</span> <span class="nf">geometry</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="o">...</span> <span class="k">def</span> <span class="nf">item_geometry</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span> <span class="o">...</span> <span class="c"># And as a function with a single argument</span> <span class="k">def</span> <span class="nf">geometry</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">):</span> <span class="o">...</span> <span class="k">def</span> <span class="nf">item_geometry</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">item</span><span class="p">):</span> <span class="o">...</span> </pre></div> </div> <dl class="method"> <dt id="django.contrib.gis.feeds.Feed.geometry"> <tt class="descname">geometry</tt>(<em>obj</em>)<a class="headerlink" href="#django.contrib.gis.feeds.Feed.geometry" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p>Takes the object returned by <tt class="docutils literal"><span class="pre">get_object()</span></tt> and returns the <em>feed’s</em> geometry. Typically this is a <tt class="docutils literal"><span class="pre">GEOSGeometry</span></tt> instance, or can be a tuple to represent a point or a box. For example:</p> <div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">ZipcodeFeed</span><span class="p">(</span><span class="n">Feed</span><span class="p">):</span> <span class="k">def</span> <span class="nf">geometry</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">):</span> <span class="c"># Can also return: `obj.poly`, and `obj.poly.centroid`.</span> <span class="k">return</span> <span class="n">obj</span><span class="o">.</span><span class="n">poly</span><span class="o">.</span><span class="n">extent</span> <span class="c"># tuple like: (X0, Y0, X1, Y1).</span> </pre></div> </div> <dl class="method"> <dt id="django.contrib.gis.feeds.Feed.item_geometry"> <tt class="descname">item_geometry</tt>(<em>item</em>)<a class="headerlink" href="#django.contrib.gis.feeds.Feed.item_geometry" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p>Set this to return the geometry for each <em>item</em> in the feed. This can be a <tt class="docutils literal"><span class="pre">GEOSGeometry</span></tt> instance, or a tuple that represents a point coordinate or bounding box. For example:</p> <div class="highlight-python"><div class="highlight"><pre><span class="k">class</span> <span class="nc">ZipcodeFeed</span><span class="p">(</span><span class="n">Feed</span><span class="p">):</span> <span class="k">def</span> <span class="nf">item_geometry</span><span class="p">(</span><span class="bp">self</span><span class="p">,</span> <span class="n">obj</span><span class="p">):</span> <span class="c"># Returns the polygon.</span> <span class="k">return</span> <span class="n">obj</span><span class="o">.</span><span class="n">poly</span> </pre></div> </div> </dd></dl> </div> <div class="section" id="s-syndicationfeed-subclasses"> <span id="syndicationfeed-subclasses"></span><h3><tt class="docutils literal"><span class="pre">SyndicationFeed</span></tt> Subclasses<a class="headerlink" href="#syndicationfeed-subclasses" title="Permalink to this headline">¶</a></h3> <p>The following <a class="reference internal" href="../../utils.html#django.utils.feedgenerator.SyndicationFeed" title="django.utils.feedgenerator.SyndicationFeed"><tt class="xref py py-class docutils literal"><span class="pre">django.utils.feedgenerator.SyndicationFeed</span></tt></a> subclasses are available:</p> <dl class="class"> <dt id="django.contrib.gis.feeds.GeoRSSFeed"> <em class="property">class </em><tt class="descname">GeoRSSFeed</tt><a class="headerlink" href="#django.contrib.gis.feeds.GeoRSSFeed" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="class"> <dt id="django.contrib.gis.feeds.GeoAtom1Feed"> <em class="property">class </em><tt class="descname">GeoAtom1Feed</tt><a class="headerlink" href="#django.contrib.gis.feeds.GeoAtom1Feed" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <dl class="class"> <dt id="django.contrib.gis.feeds.W3CGeoFeed"> <em class="property">class </em><tt class="descname">W3CGeoFeed</tt><a class="headerlink" href="#django.contrib.gis.feeds.W3CGeoFeed" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <div class="admonition note"> <p class="first admonition-title">Note</p> <p class="last"><a class="reference external" href="http://www.w3.org/2003/01/geo/">W3C Geo</a> formatted feeds only support <a class="reference internal" href="model-api.html#django.contrib.gis.db.models.PointField" title="django.contrib.gis.db.models.PointField"><tt class="xref py py-class docutils literal"><span class="pre">PointField</span></tt></a> geometries.</p> </div> </div> </div> </div> </div> </div> </div> <div class="yui-b" id="sidebar"> <div class="sphinxsidebar"> <div class="sphinxsidebarwrapper"> <h3><a href="../../../contents.html">Table Of Contents</a></h3> <ul> <li><a class="reference internal" href="#">Geographic Feeds</a><ul> <li><a class="reference internal" href="#example">Example</a></li> <li><a class="reference internal" href="#api-reference">API Reference</a><ul> <li><a class="reference internal" href="#feed-subclass"><tt class="docutils literal"><span class="pre">Feed</span></tt> Subclass</a></li> <li><a class="reference internal" href="#syndicationfeed-subclasses"><tt class="docutils literal"><span class="pre">SyndicationFeed</span></tt> Subclasses</a></li> </ul> </li> </ul> </li> </ul> <h3>Browse</h3> <ul> <li>Prev: <a href="admin.html">GeoDjango’s admin site</a></li> <li>Next: <a href="sitemaps.html">Geographic Sitemaps</a></li> </ul> <h3>You are here:</h3> <ul> <li> <a href="../../../index.html">Django 1.5.8 documentation</a> <ul><li><a href="../../index.html">API Reference</a> <ul><li><a href="../index.html"><tt class="docutils literal"><span class="pre">contrib</span></tt> packages</a> <ul><li><a href="index.html">GeoDjango</a> <ul><li>Geographic Feeds</li></ul> </li></ul></li></ul></li></ul> </li> </ul> <h3>This Page</h3> <ul class="this-page-menu"> <li><a href="../../../_sources/ref/contrib/gis/feeds.txt" rel="nofollow">Show Source</a></li> </ul> <div id="searchbox" style="display: none"> <h3>Quick search</h3> <form class="search" action="../../../search.html" method="get"> <input type="text" name="q" /> <input type="submit" value="Go" /> <input type="hidden" name="check_keywords" value="yes" /> <input type="hidden" name="area" value="default" /> </form> <p class="searchtip" style="font-size: 90%"> Enter search terms or a module, class or function name. </p> </div> <script type="text/javascript">$('#searchbox').show(0);</script> </div> </div> <h3>Last update:</h3> <p class="topless">May 15, 2014</p> </div> </div> <div id="ft"> <div class="nav"> « <a href="admin.html" title="GeoDjango&#8217;s admin site">previous</a> | <a href="../../index.html" title="API Reference" accesskey="U">up</a> | <a href="sitemaps.html" title="Geographic Sitemaps">next</a> »</div> </div> </div> <div class="clearer"></div> </div> </body> </html>