Sophie

Sophie

distrib > Mageia > 6 > armv7hl > media > core-updates > by-pkgid > 65530c6176058f9b54858c3b4f6385e6 > files > 725

python-django-doc-1.8.19-1.mga6.noarch.rpm

<!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" lang="">
  <head>
    <meta http-equiv="Content-Type" content="text/html; charset=utf-8" />
    
    <title>LayerMapping data import utility &#8212; Django 1.8.19 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.8.19',
        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="index" title="Index" href="../../../genindex.html" />
    <link rel="search" title="Search" href="../../../search.html" />
    <link rel="top" title="Django 1.8.19 documentation" href="../../../contents.html" />
    <link rel="up" title="GeoDjango Utilities" href="utils.html" />
    <link rel="next" title="OGR Inspection" href="ogrinspect.html" />
    <link rel="prev" title="GeoDjango Utilities" href="utils.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 role="document">

    <div class="document">
  <div id="custom-doc" class="yui-t6">
    <div id="hd">
      <h1><a href="../../../index.html">Django 1.8.19 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">
    &laquo; <a href="utils.html" title="GeoDjango Utilities">previous</a>
     |
    <a href="../../index.html" title="API Reference" accesskey="U">up</a>
   |
    <a href="ogrinspect.html" title="OGR Inspection">next</a> &raquo;</div>
    </div>

    <div id="bd">
      <div id="yui-main">
        <div class="yui-b">
          <div class="yui-g" id="ref-contrib-gis-layermapping">
            
  <div class="section" id="s-module-django.contrib.gis.utils.layermapping">
<span id="s-layermapping-data-import-utility"></span><span id="module-django.contrib.gis.utils.layermapping"></span><span id="layermapping-data-import-utility"></span><h1><code class="docutils literal"><span class="pre">LayerMapping</span></code> data import utility<a class="headerlink" href="#module-django.contrib.gis.utils.layermapping" title="Permalink to this headline">¶</a></h1>
<p>The <a class="reference internal" href="#django.contrib.gis.utils.LayerMapping" title="django.contrib.gis.utils.LayerMapping"><code class="xref py py-class docutils literal"><span class="pre">LayerMapping</span></code></a> class provides a way to map the contents of
vector spatial data files (e.g. shapefiles) into GeoDjango models.</p>
<p>This utility grew out of the author&#8217;s personal needs to eliminate
the code repetition that went into pulling geometries and fields out of
a vector layer, converting to another coordinate system (e.g. WGS84), and
then inserting into a GeoDjango model.</p>
<div class="admonition note">
<p class="first admonition-title">Note</p>
<p class="last">Use of <a class="reference internal" href="#django.contrib.gis.utils.LayerMapping" title="django.contrib.gis.utils.LayerMapping"><code class="xref py py-class docutils literal"><span class="pre">LayerMapping</span></code></a> requires GDAL.</p>
</div>
<div class="admonition warning">
<p class="first admonition-title">Warning</p>
<p class="last">GIS data sources, like shapefiles, may be very large.  If you find
that <a class="reference internal" href="#django.contrib.gis.utils.LayerMapping" title="django.contrib.gis.utils.LayerMapping"><code class="xref py py-class docutils literal"><span class="pre">LayerMapping</span></code></a> is using too much memory, set
<a class="reference internal" href="../../settings.html#std:setting-DEBUG"><code class="xref std std-setting docutils literal"><span class="pre">DEBUG</span></code></a> to <code class="docutils literal"><span class="pre">False</span></code> in your settings.  When <a class="reference internal" href="../../settings.html#std:setting-DEBUG"><code class="xref std std-setting docutils literal"><span class="pre">DEBUG</span></code></a>
is set to <code class="docutils literal"><span class="pre">True</span></code>, Django <a class="reference internal" href="../../../faq/models.html#faq-see-raw-sql-queries"><span class="std std-ref">automatically logs</span></a>
<em>every</em> SQL query &#8211; thus, when SQL statements contain geometries, it is
easy to consume more memory than is typical.</p>
</div>
<div class="section" id="s-example">
<span id="example"></span><h2>Example<a class="headerlink" href="#example" title="Permalink to this headline">¶</a></h2>
<ol class="arabic">
<li><p class="first">You need a GDAL-supported data source, like a shapefile (here we&#8217;re using
a simple polygon shapefile, <code class="docutils literal"><span class="pre">test_poly.shp</span></code>, with three features):</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.gis.gdal</span> <span class="k">import</span> <span class="n">DataSource</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">ds</span> <span class="o">=</span> <span class="n">DataSource</span><span class="p">(</span><span class="s1">&#39;test_poly.shp&#39;</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">layer</span> <span class="o">=</span> <span class="n">ds</span><span class="p">[</span><span class="mi">0</span><span class="p">]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">layer</span><span class="o">.</span><span class="n">fields</span><span class="p">)</span> <span class="c1"># Exploring the fields in the layer, we only want the &#39;str&#39; field.</span>
<span class="go">[&#39;float&#39;, &#39;int&#39;, &#39;str&#39;]</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="nb">len</span><span class="p">(</span><span class="n">layer</span><span class="p">))</span> <span class="c1"># getting the number of features in the layer (should be 3)</span>
<span class="go">3</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">layer</span><span class="o">.</span><span class="n">geom_type</span><span class="p">)</span> <span class="c1"># Should be &#39;Polygon&#39;</span>
<span class="go">Polygon</span>
<span class="gp">&gt;&gt;&gt; </span><span class="nb">print</span><span class="p">(</span><span class="n">layer</span><span class="o">.</span><span class="n">srs</span><span class="p">)</span> <span class="c1"># WGS84 in WKT</span>
<span class="go">GEOGCS[&quot;GCS_WGS_1984&quot;,</span>
<span class="go">    DATUM[&quot;WGS_1984&quot;,</span>
<span class="go">        SPHEROID[&quot;WGS_1984&quot;,6378137,298.257223563]],</span>
<span class="go">    PRIMEM[&quot;Greenwich&quot;,0],</span>
<span class="go">    UNIT[&quot;Degree&quot;,0.017453292519943295]]</span>
</pre></div>
</div>
</li>
<li><p class="first">Now we define our corresponding Django model (make sure to use <a class="reference internal" href="../../django-admin.html#django-admin-migrate"><code class="xref std std-djadmin docutils literal"><span class="pre">migrate</span></code></a>):</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="kn">from</span> <span class="nn">django.contrib.gis.db</span> <span class="k">import</span> <span class="n">models</span>

<span class="k">class</span> <span class="nc">TestGeo</span><span class="p">(</span><span class="n">models</span><span class="o">.</span><span class="n">Model</span><span class="p">):</span>
    <span class="n">name</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">CharField</span><span class="p">(</span><span class="n">max_length</span><span class="o">=</span><span class="mi">25</span><span class="p">)</span> <span class="c1"># corresponds to the &#39;str&#39; field</span>
    <span class="n">poly</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">PolygonField</span><span class="p">(</span><span class="n">srid</span><span class="o">=</span><span class="mi">4269</span><span class="p">)</span> <span class="c1"># we want our model in a different SRID</span>
    <span class="n">objects</span> <span class="o">=</span> <span class="n">models</span><span class="o">.</span><span class="n">GeoManager</span><span class="p">()</span>

    <span class="k">def</span> <span class="nf">__str__</span><span class="p">(</span><span class="bp">self</span><span class="p">):</span>              <span class="c1"># __unicode__ on Python 2</span>
        <span class="k">return</span> <span class="s1">&#39;Name: </span><span class="si">%s</span><span class="s1">&#39;</span> <span class="o">%</span> <span class="bp">self</span><span class="o">.</span><span class="n">name</span>
</pre></div>
</div>
</li>
<li><p class="first">Use <a class="reference internal" href="#django.contrib.gis.utils.LayerMapping" title="django.contrib.gis.utils.LayerMapping"><code class="xref py py-class docutils literal"><span class="pre">LayerMapping</span></code></a> to extract all the features and place them in the
database:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">django.contrib.gis.utils</span> <span class="k">import</span> <span class="n">LayerMapping</span>
<span class="gp">&gt;&gt;&gt; </span><span class="kn">from</span> <span class="nn">geoapp.models</span> <span class="k">import</span> <span class="n">TestGeo</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">mapping</span> <span class="o">=</span> <span class="p">{</span><span class="s1">&#39;name&#39;</span> <span class="p">:</span> <span class="s1">&#39;str&#39;</span><span class="p">,</span> <span class="c1"># The &#39;name&#39; model field maps to the &#39;str&#39; layer field.</span>
<span class="go">               &#39;poly&#39; : &#39;POLYGON&#39;, # For geometry fields use OGC name.</span>
<span class="go">               } # The mapping is a dictionary</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">lm</span> <span class="o">=</span> <span class="n">LayerMapping</span><span class="p">(</span><span class="n">TestGeo</span><span class="p">,</span> <span class="s1">&#39;test_poly.shp&#39;</span><span class="p">,</span> <span class="n">mapping</span><span class="p">)</span>
<span class="gp">&gt;&gt;&gt; </span><span class="n">lm</span><span class="o">.</span><span class="n">save</span><span class="p">(</span><span class="n">verbose</span><span class="o">=</span><span class="kc">True</span><span class="p">)</span> <span class="c1"># Save the layermap, imports the data.</span>
<span class="go">Saved: Name: 1</span>
<span class="go">Saved: Name: 2</span>
<span class="go">Saved: Name: 3</span>
</pre></div>
</div>
</li>
</ol>
<p>Here, <a class="reference internal" href="#django.contrib.gis.utils.LayerMapping" title="django.contrib.gis.utils.LayerMapping"><code class="xref py py-class docutils literal"><span class="pre">LayerMapping</span></code></a> just transformed the three geometries from the
shapefile in their original spatial reference system (WGS84) to the spatial
reference system of the GeoDjango model (NAD83).  If no spatial reference
system is defined for the layer, use the <code class="docutils literal"><span class="pre">source_srs</span></code> keyword with a
<a class="reference internal" href="gdal.html#django.contrib.gis.gdal.SpatialReference" title="django.contrib.gis.gdal.SpatialReference"><code class="xref py py-class docutils literal"><span class="pre">SpatialReference</span></code></a> object to specify one.</p>
</div>
<div class="section" id="s-layermapping-api">
<span id="layermapping-api"></span><h2><code class="docutils literal"><span class="pre">LayerMapping</span></code> API<a class="headerlink" href="#layermapping-api" title="Permalink to this headline">¶</a></h2>
<dl class="class">
<dt id="django.contrib.gis.utils.LayerMapping">
<em class="property">class </em><code class="descname">LayerMapping</code>(<em>model</em>, <em>data_source</em>, <em>mapping</em>, <em>layer=0</em>, <em>source_srs=None</em>, <em>encoding=None</em>, <em>transaction_mode='commit_on_success'</em>, <em>transform=True</em>, <em>unique=True</em>, <em>using='default'</em>)<a class="headerlink" href="#django.contrib.gis.utils.LayerMapping" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>The following are the arguments and keywords that may be used during
instantiation of <code class="docutils literal"><span class="pre">LayerMapping</span></code> objects.</p>
<table class="docutils">
<colgroup>
<col width="23%" />
<col width="77%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Argument</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">model</span></code></td>
<td>The geographic model, <em>not</em> an instance.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">data_source</span></code></td>
<td>The path to the OGR-supported data source file
(e.g., a shapefile).  Also accepts
<a class="reference internal" href="gdal.html#django.contrib.gis.gdal.DataSource" title="django.contrib.gis.gdal.DataSource"><code class="xref py py-class docutils literal"><span class="pre">django.contrib.gis.gdal.DataSource</span></code></a> instances.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">mapping</span></code></td>
<td>A dictionary: keys are strings corresponding to
the model field, and values correspond to
string field names for the OGR feature, or if the
model field is a geographic then it should
correspond to the OGR geometry type,
e.g., <code class="docutils literal"><span class="pre">'POINT'</span></code>, <code class="docutils literal"><span class="pre">'LINESTRING'</span></code>, <code class="docutils literal"><span class="pre">'POLYGON'</span></code>.</td>
</tr>
</tbody>
</table>
<table class="docutils">
<colgroup>
<col width="28%" />
<col width="72%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Keyword Arguments</th>
<th class="head">&nbsp;</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">layer</span></code></td>
<td>The index of the layer to use from the Data Source
(defaults to 0)</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">source_srs</span></code></td>
<td>Use this to specify the source SRS manually (for
example, some shapefiles don&#8217;t come with a <code class="docutils literal"><span class="pre">'.prj'</span></code>
file).  An integer SRID, WKT or PROJ.4 strings, and
<a class="reference internal" href="gdal.html#django.contrib.gis.gdal.SpatialReference" title="django.contrib.gis.gdal.SpatialReference"><code class="xref py py-class docutils literal"><span class="pre">django.contrib.gis.gdal.SpatialReference</span></code></a>
objects are accepted.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">encoding</span></code></td>
<td>Specifies the character set encoding of the strings
in the OGR data source.  For example, <code class="docutils literal"><span class="pre">'latin-1'</span></code>,
<code class="docutils literal"><span class="pre">'utf-8'</span></code>, and <code class="docutils literal"><span class="pre">'cp437'</span></code> are all valid encoding
parameters.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">transaction_mode</span></code></td>
<td>May be <code class="docutils literal"><span class="pre">'commit_on_success'</span></code> (default) or
<code class="docutils literal"><span class="pre">'autocommit'</span></code>.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">transform</span></code></td>
<td>Setting this to False will disable coordinate
transformations.  In other words, geometries will
be inserted into the database unmodified from their
original state in the data source.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">unique</span></code></td>
<td>Setting this to the name, or a tuple of names,
from the given  model will create models unique
only to the given name(s). Geometries will from
each feature will be added into the collection
associated with the unique model.  Forces
the transaction mode to be <code class="docutils literal"><span class="pre">'autocommit'</span></code>.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">using</span></code></td>
<td>Sets the database to use when importing spatial data.
Default is <code class="docutils literal"><span class="pre">'default'</span></code>.</td>
</tr>
</tbody>
</table>
<div class="section" id="s-save-keyword-arguments">
<span id="save-keyword-arguments"></span><h3><code class="docutils literal"><span class="pre">save()</span></code> Keyword Arguments<a class="headerlink" href="#save-keyword-arguments" title="Permalink to this headline">¶</a></h3>
<dl class="method">
<dt id="django.contrib.gis.utils.LayerMapping.save">
<code class="descclassname">LayerMapping.</code><code class="descname">save</code>(<em>verbose=False</em>, <em>fid_range=False</em>, <em>step=False</em>, <em>progress=False</em>, <em>silent=False</em>, <em>stream=sys.stdout</em>, <em>strict=False</em>)<a class="headerlink" href="#django.contrib.gis.utils.LayerMapping.save" title="Permalink to this definition">¶</a></dt>
<dd></dd></dl>

<p>The <code class="docutils literal"><span class="pre">save()</span></code> method also accepts keywords.  These keywords are
used for controlling output logging, error handling, and for importing
specific feature ranges.</p>
<table class="docutils">
<colgroup>
<col width="36%" />
<col width="64%" />
</colgroup>
<thead valign="bottom">
<tr class="row-odd"><th class="head">Save Keyword Arguments</th>
<th class="head">Description</th>
</tr>
</thead>
<tbody valign="top">
<tr class="row-even"><td><code class="docutils literal"><span class="pre">fid_range</span></code></td>
<td>May be set with a slice or tuple of
(begin, end) feature ID&#8217;s to map from
the data source.  In other words, this
keyword enables the user to selectively
import a subset range of features in the
geographic data source.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">progress</span></code></td>
<td>When this keyword is set, status information
will be printed giving the number of features
processed and successfully saved.  By default,
progress information will be printed every 1000
features processed, however, this default may
be overridden by setting this keyword with an
integer for the desired interval.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">silent</span></code></td>
<td>By default, non-fatal error notifications are
printed to <code class="docutils literal"><span class="pre">sys.stdout</span></code>, but this keyword may
be set to disable these notifications.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">step</span></code></td>
<td>If set with an integer, transactions will
occur at every step interval. For example, if
<code class="docutils literal"><span class="pre">step=1000</span></code>, a commit would occur after the
1,000th feature, the 2,000th feature etc.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">stream</span></code></td>
<td>Status information will be written to this file
handle.  Defaults to using <code class="docutils literal"><span class="pre">sys.stdout</span></code>, but
any object with a <code class="docutils literal"><span class="pre">write</span></code> method is supported.</td>
</tr>
<tr class="row-odd"><td><code class="docutils literal"><span class="pre">strict</span></code></td>
<td>Execution of the model mapping will cease upon
the first error encountered.  The default value
(<code class="docutils literal"><span class="pre">False</span></code>)
behavior is to attempt to continue.</td>
</tr>
<tr class="row-even"><td><code class="docutils literal"><span class="pre">verbose</span></code></td>
<td>If set, information will be printed
subsequent to each model save
executed on the database.</td>
</tr>
</tbody>
</table>
</div>
</div>
<div class="section" id="s-troubleshooting">
<span id="troubleshooting"></span><h2>Troubleshooting<a class="headerlink" href="#troubleshooting" title="Permalink to this headline">¶</a></h2>
<div class="section" id="s-running-out-of-memory">
<span id="running-out-of-memory"></span><h3>Running out of memory<a class="headerlink" href="#running-out-of-memory" title="Permalink to this headline">¶</a></h3>
<p>As noted in the warning at the top of this section, Django stores all SQL
queries when <code class="docutils literal"><span class="pre">DEBUG=True</span></code>.  Set <code class="docutils literal"><span class="pre">DEBUG=False</span></code> in your settings, and this
should stop excessive memory use when running <code class="docutils literal"><span class="pre">LayerMapping</span></code> scripts.</p>
</div>
<div class="section" id="s-mysql-max-allowed-packet-error">
<span id="mysql-max-allowed-packet-error"></span><h3>MySQL: <code class="docutils literal"><span class="pre">max_allowed_packet</span></code> error<a class="headerlink" href="#mysql-max-allowed-packet-error" title="Permalink to this headline">¶</a></h3>
<p>If you encounter the following error when using <code class="docutils literal"><span class="pre">LayerMapping</span></code> and MySQL:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">OperationalError</span><span class="p">:</span> <span class="p">(</span><span class="mi">1153</span><span class="p">,</span> <span class="s2">&quot;Got a packet bigger than &#39;max_allowed_packet&#39; bytes&quot;</span><span class="p">)</span>
</pre></div>
</div>
<p>Then the solution is to increase the value of the <code class="docutils literal"><span class="pre">max_allowed_packet</span></code>
setting in your MySQL configuration.  For example, the default value may
be something low like one megabyte &#8211; the setting may be modified in MySQL&#8217;s
configuration file (<code class="docutils literal"><span class="pre">my.cnf</span></code>) in the <code class="docutils literal"><span class="pre">[mysqld]</span></code> section:</p>
<div class="highlight-default"><div class="highlight"><pre><span></span><span class="n">max_allowed_packet</span> <span class="o">=</span> <span class="mi">10</span><span class="n">M</span>
</pre></div>
</div>
</div>
</div>
</div>


          </div>
        </div>
      </div>
      
        
          <div class="yui-b" id="sidebar">
            
      <div class="sphinxsidebar" role="navigation" aria-label="main navigation">
        <div class="sphinxsidebarwrapper">
  <h3><a href="../../../contents.html">Table Of Contents</a></h3>
  <ul>
<li><a class="reference internal" href="#"><code class="docutils literal"><span class="pre">LayerMapping</span></code> data import utility</a><ul>
<li><a class="reference internal" href="#example">Example</a></li>
<li><a class="reference internal" href="#layermapping-api"><code class="docutils literal"><span class="pre">LayerMapping</span></code> API</a><ul>
<li><a class="reference internal" href="#save-keyword-arguments"><code class="docutils literal"><span class="pre">save()</span></code> Keyword Arguments</a></li>
</ul>
</li>
<li><a class="reference internal" href="#troubleshooting">Troubleshooting</a><ul>
<li><a class="reference internal" href="#running-out-of-memory">Running out of memory</a></li>
<li><a class="reference internal" href="#mysql-max-allowed-packet-error">MySQL: <code class="docutils literal"><span class="pre">max_allowed_packet</span></code> error</a></li>
</ul>
</li>
</ul>
</li>
</ul>

  <h3>Browse</h3>
  <ul>
    
      <li>Prev: <a href="utils.html">GeoDjango Utilities</a></li>
    
    
      <li>Next: <a href="ogrinspect.html">OGR Inspection</a></li>
    
  </ul>
  <h3>You are here:</h3>
  <ul>
      <li>
        <a href="../../../index.html">Django 1.8.19 documentation</a>
        
          <ul><li><a href="../../index.html">API Reference</a>
        
          <ul><li><a href="../index.html"><code class="docutils literal"><span class="pre">contrib</span></code> packages</a>
        
          <ul><li><a href="index.html">GeoDjango</a>
        
          <ul><li><a href="utils.html">GeoDjango Utilities</a>
        
        <ul><li><code class="docutils literal"><span class="pre">LayerMapping</span></code> data import utility</li></ul>
        </li></ul></li></ul></li></ul></li></ul>
      </li>
  </ul>

  <div role="note" aria-label="source link">
    <h3>This Page</h3>
    <ul class="this-page-menu">
      <li><a href="../../../_sources/ref/contrib/gis/layermapping.txt"
            rel="nofollow">Show Source</a></li>
    </ul>
   </div>
<div id="searchbox" style="display: none" role="search">
  <h3>Quick search</h3>
    <form class="search" action="../../../search.html" method="get">
      <div><input type="text" name="q" /></div>
      <div><input type="submit" value="Go" /></div>
      <input type="hidden" name="check_keywords" value="yes" />
      <input type="hidden" name="area" value="default" />
    </form>
</div>
<script type="text/javascript">$('#searchbox').show(0);</script>
        </div>
      </div>
              <h3>Last update:</h3>
              <p class="topless">Mar 10, 2018</p>
          </div>
        
      
    </div>

    <div id="ft">
      <div class="nav">
    &laquo; <a href="utils.html" title="GeoDjango Utilities">previous</a>
     |
    <a href="../../index.html" title="API Reference" accesskey="U">up</a>
   |
    <a href="ogrinspect.html" title="OGR Inspection">next</a> &raquo;</div>
    </div>
  </div>

      <div class="clearer"></div>
    </div>
  </body>
</html>