<!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>GeoDjango Management Commands — 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="GeoDjango’s admin site" href="admin.html" /> <link rel="prev" title="OGR Inspection" href="ogrinspect.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="ogrinspect.html" title="OGR Inspection">previous</a> | <a href="../../index.html" title="API Reference" accesskey="U">up</a> | <a href="admin.html" title="GeoDjango&#8217;s admin site">next</a> »</div> </div> <div id="bd"> <div id="yui-main"> <div class="yui-b"> <div class="yui-g" id="ref-contrib-gis-commands"> <div class="section" id="s-geodjango-management-commands"> <span id="geodjango-management-commands"></span><h1>GeoDjango Management Commands<a class="headerlink" href="#geodjango-management-commands" title="Permalink to this headline">¶</a></h1> <div class="section" id="s-inspectdb"> <span id="inspectdb"></span><h2>inspectdb<a class="headerlink" href="#inspectdb" title="Permalink to this headline">¶</a></h2> <dl class="describe"> <dt> <tt class="descname">django-admin.py inspectdb</tt></dt> <dd></dd></dl> <p>When <a class="reference internal" href="index.html#module-django.contrib.gis" title="django.contrib.gis: Geographic Information System (GIS) extensions for Django"><tt class="xref py py-mod docutils literal"><span class="pre">django.contrib.gis</span></tt></a> is in your <a class="reference internal" href="../../settings.html#std:setting-INSTALLED_APPS"><tt class="xref std std-setting docutils literal"><span class="pre">INSTALLED_APPS</span></tt></a>, the <a class="reference internal" href="../../django-admin.html#django-admin-inspectdb"><tt class="xref std std-djadmin docutils literal"><span class="pre">inspectdb</span></tt></a> management command is overridden with one from GeoDjango. The overridden command is spatially-aware, and places geometry fields in the auto-generated model definition, where appropriate.</p> </div> <div class="section" id="s-ogrinspect-data-source-model-name"> <span id="ogrinspect-data-source-model-name"></span><h2>ogrinspect <data_source> <model_name><a class="headerlink" href="#ogrinspect-data-source-model-name" title="Permalink to this headline">¶</a></h2> <dl class="django-admin"> <dt id="django-admin-ogrinspect"> <tt class="descname">django-admin.py ogrinspect</tt><a class="headerlink" href="#django-admin-ogrinspect" title="Permalink to this definition">¶</a></dt> <dd></dd></dl> <p>The <tt class="docutils literal"><span class="pre">ogrinpsect</span></tt> management command will inspect the given OGR-compatible <a class="reference internal" href="gdal.html#django.contrib.gis.gdal.DataSource" title="django.contrib.gis.gdal.DataSource"><tt class="xref py py-class docutils literal"><span class="pre">DataSource</span></tt></a> (e.g., a shapefile) and will output a GeoDjango model with the given model name. There’s a detailed example of using <tt class="docutils literal"><span class="pre">ogrinspect</span></tt> <a class="reference internal" href="tutorial.html#ogrinspect-intro"><em>in the tutorial</em></a>.</p> <dl class="django-admin-option"> <dt id="django-admin-option---blank"> <tt class="descname">--blank</tt><tt class="descclassname"> <blank_field(s)></tt><a class="headerlink" href="#django-admin-option---blank" title="Permalink to this definition">¶</a></dt> <dd><p>Use a comma separated list of OGR field names to add the <tt class="docutils literal"><span class="pre">blank=True</span></tt> keyword option to the field definition. Set with <tt class="docutils literal"><span class="pre">true</span></tt> to apply to all applicable fields.</p> </dd></dl> <dl class="django-admin-option"> <dt id="django-admin-option---decimal"> <tt class="descname">--decimal</tt><tt class="descclassname"> <decimal_field(s)></tt><a class="headerlink" href="#django-admin-option---decimal" title="Permalink to this definition">¶</a></dt> <dd><p>Use a comma separated list of OGR float fields to generate <a class="reference internal" href="../../models/fields.html#django.db.models.DecimalField" title="django.db.models.DecimalField"><tt class="xref py py-class docutils literal"><span class="pre">DecimalField</span></tt></a> instead of the default <a class="reference internal" href="../../models/fields.html#django.db.models.FloatField" title="django.db.models.FloatField"><tt class="xref py py-class docutils literal"><span class="pre">FloatField</span></tt></a>. Set to <tt class="docutils literal"><span class="pre">true</span></tt> to apply to all OGR float fields.</p> </dd></dl> <dl class="django-admin-option"> <dt id="django-admin-option---geom-name"> <tt class="descname">--geom-name</tt><tt class="descclassname"> <name></tt><a class="headerlink" href="#django-admin-option---geom-name" title="Permalink to this definition">¶</a></dt> <dd><p>Specifies the model attribute name to use for the geometry field. Defaults to <tt class="docutils literal"><span class="pre">'geom'</span></tt>.</p> </dd></dl> <dl class="django-admin-option"> <dt id="django-admin-option---layer"> <tt class="descname">--layer</tt><tt class="descclassname"> <layer></tt><a class="headerlink" href="#django-admin-option---layer" title="Permalink to this definition">¶</a></dt> <dd><p>The key for specifying which layer in the OGR <a class="reference internal" href="gdal.html#django.contrib.gis.gdal.DataSource" title="django.contrib.gis.gdal.DataSource"><tt class="xref py py-class docutils literal"><span class="pre">DataSource</span></tt></a> source to use. Defaults to 0 (the first layer). May be an integer or a string identifier for the <a class="reference internal" href="gdal.html#django.contrib.gis.gdal.Layer" title="django.contrib.gis.gdal.Layer"><tt class="xref py py-class docutils literal"><span class="pre">Layer</span></tt></a>.</p> </dd></dl> <dl class="django-admin-option"> <dt id="django-admin-option---mapping"> <tt class="descname">--mapping</tt><tt class="descclassname"></tt><a class="headerlink" href="#django-admin-option---mapping" title="Permalink to this definition">¶</a></dt> <dd><p>Automatically generate a mapping dictionary for use with <a class="reference internal" href="layermapping.html#django.contrib.gis.utils.LayerMapping" title="django.contrib.gis.utils.LayerMapping"><tt class="xref py py-class docutils literal"><span class="pre">LayerMapping</span></tt></a>.</p> </dd></dl> <dl class="django-admin-option"> <dt id="django-admin-option---multi-geom"> <tt class="descname">--multi-geom</tt><tt class="descclassname"></tt><a class="headerlink" href="#django-admin-option---multi-geom" title="Permalink to this definition">¶</a></dt> <dd><p>When generating the geometry field, treat it as a geometry collection. For example, if this setting is enabled then a <a class="reference internal" href="model-api.html#django.contrib.gis.db.models.MultiPolygonField" title="django.contrib.gis.db.models.MultiPolygonField"><tt class="xref py py-class docutils literal"><span class="pre">MultiPolygonField</span></tt></a> will be placed in the generated model rather than <a class="reference internal" href="model-api.html#django.contrib.gis.db.models.PolygonField" title="django.contrib.gis.db.models.PolygonField"><tt class="xref py py-class docutils literal"><span class="pre">PolygonField</span></tt></a>.</p> </dd></dl> <dl class="django-admin-option"> <dt id="django-admin-option---name-field"> <tt class="descname">--name-field</tt><tt class="descclassname"> <name_field></tt><a class="headerlink" href="#django-admin-option---name-field" title="Permalink to this definition">¶</a></dt> <dd><p>Generates a <tt class="docutils literal"><span class="pre">__unicode__</span></tt> routine on the model that will return the the given field name.</p> </dd></dl> <dl class="django-admin-option"> <dt id="django-admin-option---no-imports"> <tt class="descname">--no-imports</tt><tt class="descclassname"></tt><a class="headerlink" href="#django-admin-option---no-imports" title="Permalink to this definition">¶</a></dt> <dd><p>Suppresses the <tt class="docutils literal"><span class="pre">from</span> <span class="pre">django.contrib.gis.db</span> <span class="pre">import</span> <span class="pre">models</span></tt> import statement.</p> </dd></dl> <dl class="django-admin-option"> <dt id="django-admin-option---null"> <tt class="descname">--null</tt><tt class="descclassname"> <null_field(s)></tt><a class="headerlink" href="#django-admin-option---null" title="Permalink to this definition">¶</a></dt> <dd><p>Use a comma separated list of OGR field names to add the <tt class="docutils literal"><span class="pre">null=True</span></tt> keyword option to the field definition. Set with <tt class="docutils literal"><span class="pre">true</span></tt> to apply to all applicable fields.</p> </dd></dl> <dl class="django-admin-option"> <dt id="django-admin-option---srid"> <tt class="descname">--srid</tt><tt class="descclassname"></tt><a class="headerlink" href="#django-admin-option---srid" title="Permalink to this definition">¶</a></dt> <dd><p>The SRID to use for the geometry field. If not set, <tt class="docutils literal"><span class="pre">ogrinspect</span></tt> attempts to automatically determine of the SRID of the data source.</p> </dd></dl> </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="#">GeoDjango Management Commands</a><ul> <li><a class="reference internal" href="#inspectdb">inspectdb</a></li> <li><a class="reference internal" href="#ogrinspect-data-source-model-name">ogrinspect <data_source> <model_name></a></li> </ul> </li> </ul> <h3>Browse</h3> <ul> <li>Prev: <a href="ogrinspect.html">OGR Inspection</a></li> <li>Next: <a href="admin.html">GeoDjango’s admin site</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>GeoDjango Management Commands</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/commands.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="ogrinspect.html" title="OGR Inspection">previous</a> | <a href="../../index.html" title="API Reference" accesskey="U">up</a> | <a href="admin.html" title="GeoDjango&#8217;s admin site">next</a> »</div> </div> </div> <div class="clearer"></div> </div> </body> </html>