Skip to content
This repository

HTTPS clone URL

Subversion checkout URL

You can clone with HTTPS or Subversion.

Download ZIP
Browse code

Fixed #13429 -- Changed `WorldBorders` to just `WorldBorder` in GeoDj…

…ango tutorial. Thanks, tubaman for the bug report.

git-svn-id: http://code.djangoproject.com/svn/django/trunk@16798 bcc190cf-cafb-0310-a4f2-bffc1f526a37
  • Loading branch information...
commit ccbca7a668b4d02408e707cb9ed34204a8094f01 1 parent a25413b
Justin Bronn authored September 11, 2011
2  docs/ref/contrib/gis/geoquerysets.txt
@@ -1203,7 +1203,7 @@ Aggregate Functions
1203 1203
 Example::
1204 1204
 
1205 1205
     >>> from django.contrib.gis.db.models import Extent, Union
1206  
-    >>> WorldBorders.objects.aggregate(Extent('mpoly'), Union('mpoly'))
  1206
+    >>> WorldBorder.objects.aggregate(Extent('mpoly'), Union('mpoly'))
1207 1207
 
1208 1208
 ``Collect``
1209 1209
 ~~~~~~~~~~~
52  docs/ref/contrib/gis/tutorial.txt
@@ -212,7 +212,7 @@ create a GeoDjango model to represent this data::
212 212
 
213 213
     from django.contrib.gis.db import models
214 214
 
215  
-    class WorldBorders(models.Model):
  215
+    class WorldBorder(models.Model):
216 216
         # Regular Django fields corresponding to the attributes in the
217 217
 	# world borders shapefile.
218 218
         name = models.CharField(max_length=50)
@@ -232,10 +232,6 @@ create a GeoDjango model to represent this data::
232 232
 	mpoly = models.MultiPolygonField()
233 233
 	objects = models.GeoManager()
234 234
 
235  
-        # So the model is pluralized correctly in the admin.
236  
-        class Meta:
237  
-            verbose_name_plural = "World Borders"
238  
-
239 235
         # Returns the string representation of the model.
240 236
         def __unicode__(self):
241 237
             return self.name
@@ -259,7 +255,7 @@ Run ``syncdb``
259 255
 --------------
260 256
 
261 257
 After you've defined your model, it needs to be synced with the spatial database.
262  
-First, let's look at the SQL that will generate the table for the ``WorldBorders``
  258
+First, let's look at the SQL that will generate the table for the ``WorldBorder``
263 259
 model::
264 260
 
265 261
     $ python manage.py sqlall world
@@ -292,7 +288,7 @@ If satisfied, you may then create this table in the database by running the
292 288
 
293 289
     $ python manage.py syncdb
294 290
     Creating table world_worldborders
295  
-    Installing custom SQL for world.WorldBorders model
  291
+    Installing custom SQL for world.WorldBorder model
296 292
 
297 293
 The ``syncdb`` command may also prompt you to create an admin user; go ahead and
298 294
 do so (not required now, may be done at any point in the future using the
@@ -445,7 +441,7 @@ We're going to dive right in -- create a file called ``load.py`` inside the
445 441
 
446 442
     import os
447 443
     from django.contrib.gis.utils import LayerMapping
448  
-    from models import WorldBorders
  444
+    from models import WorldBorder
449 445
 
450 446
     world_mapping = {
451 447
         'fips' : 'FIPS',
@@ -465,7 +461,7 @@ We're going to dive right in -- create a file called ``load.py`` inside the
465 461
     world_shp = os.path.abspath(os.path.join(os.path.dirname(__file__), 'data/TM_WORLD_BORDERS-0.3.shp'))
466 462
 
467 463
     def run(verbose=True):
468  
-        lm = LayerMapping(WorldBorders, world_shp, world_mapping,
  464
+        lm = LayerMapping(WorldBorder, world_shp, world_mapping,
469 465
                           transform=False, encoding='iso-8859-1')
470 466
 
471 467
         lm.save(strict=True, verbose=verbose)
@@ -473,7 +469,7 @@ We're going to dive right in -- create a file called ``load.py`` inside the
473 469
 A few notes about what's going on:
474 470
 
475 471
 * Each key in the ``world_mapping`` dictionary corresponds to a field in the
476  
-  ``WorldBorders`` model, and the value is the name of the shapefile field
  472
+  ``WorldBorder`` model, and the value is the name of the shapefile field
477 473
   that data will be loaded from.
478 474
 * The key ``mpoly`` for the geometry field is ``MULTIPOLYGON``, the
479 475
   geometry type we wish to import as.  Even if simple polygons are encountered
@@ -517,10 +513,10 @@ Where ``data_source`` is the path to the GDAL-supported data source and
517 513
 ``model_name`` is the name to use for the model.  Command-line options may
518 514
 be used to further define how the model is generated.
519 515
 
520  
-For example, the following command nearly reproduces the ``WorldBorders`` model
  516
+For example, the following command nearly reproduces the ``WorldBorder`` model
521 517
 and mapping dictionary created above, automatically::
522 518
 
523  
-    $ python manage.py ogrinspect world/data/TM_WORLD_BORDERS-0.3.shp WorldBorders --srid=4326 --mapping --multi
  519
+    $ python manage.py ogrinspect world/data/TM_WORLD_BORDERS-0.3.shp WorldBorder --srid=4326 --mapping --multi
524 520
 
525 521
 A few notes about the command-line options given above:
526 522
 
@@ -537,7 +533,7 @@ directly into the ``models.py`` of a GeoDjango application::
537 533
     # This is an auto-generated Django model module created by ogrinspect.
538 534
     from django.contrib.gis.db import models
539 535
 
540  
-    class WorldBorders(models.Model):
  536
+    class WorldBorder(models.Model):
541 537
         fips = models.CharField(max_length=2)
542 538
         iso2 = models.CharField(max_length=2)
543 539
         iso3 = models.CharField(max_length=3)
@@ -552,7 +548,7 @@ directly into the ``models.py`` of a GeoDjango application::
552 548
         geom = models.MultiPolygonField(srid=4326)
553 549
         objects = models.GeoManager()
554 550
 
555  
-    # Auto-generated `LayerMapping` dictionary for WorldBorders model
  551
+    # Auto-generated `LayerMapping` dictionary for WorldBorder model
556 552
     worldborders_mapping = {
557 553
         'fips' : 'FIPS',
558 554
         'iso2' : 'ISO2',
@@ -586,25 +582,25 @@ Now, define a point of interest [#]_::
586 582
 The ``pnt_wkt`` string represents the point at -95.3385 degrees longitude,
587 583
 and 29.7245 degrees latitude.  The geometry is in a format known as
588 584
 Well Known Text (WKT), an open standard issued by the Open Geospatial
589  
-Consortium (OGC). [#]_  Import the ``WorldBorders`` model, and perform
  585
+Consortium (OGC). [#]_  Import the ``WorldBorder`` model, and perform
590 586
 a ``contains`` lookup using the ``pnt_wkt`` as the parameter::
591 587
 
592  
-    >>> from world.models import WorldBorders
593  
-    >>> qs = WorldBorders.objects.filter(mpoly__contains=pnt_wkt)
  588
+    >>> from world.models import WorldBorder
  589
+    >>> qs = WorldBorder.objects.filter(mpoly__contains=pnt_wkt)
594 590
     >>> qs
595  
-    [<WorldBorders: United States>]
  591
+    [<WorldBorder: United States>]
596 592
 
597 593
 Here we retrieved a ``GeoQuerySet`` that has only one model: the one
598 594
 for the United States (which is what we would expect).  Similarly,
599 595
 a :ref:`GEOS geometry object <ref-geos>` may also be used -- here the ``intersects``
600 596
 spatial lookup is combined with the ``get`` method to retrieve
601  
-only the ``WorldBorders`` instance for San Marino instead of a queryset::
  597
+only the ``WorldBorder`` instance for San Marino instead of a queryset::
602 598
 
603 599
     >>> from django.contrib.gis.geos import Point
604 600
     >>> pnt = Point(12.4604, 43.9420)
605  
-    >>> sm = WorldBorders.objects.get(mpoly__intersects=pnt)
  601
+    >>> sm = WorldBorder.objects.get(mpoly__intersects=pnt)
606 602
     >>> sm
607  
-    <WorldBorders: San Marino>
  603
+    <WorldBorder: San Marino>
608 604
 
609 605
 The ``contains`` and ``intersects`` lookups are just a subset of what's
610 606
 available -- the :ref:`ref-gis-db-api` documentation has more.
@@ -629,7 +625,7 @@ When using GeoDjango's ORM, it will automatically wrap geometry values
629 625
 in transformation SQL, allowing the developer to work at a higher level
630 626
 of abstraction::
631 627
 
632  
-    >>> qs = WorldBorders.objects.filter(mpoly__intersects=pnt)
  628
+    >>> qs = WorldBorder.objects.filter(mpoly__intersects=pnt)
633 629
     >>> print qs.query # Generating the SQL
634 630
     SELECT "world_worldborders"."id", "world_worldborders"."name", "world_worldborders"."area",
635 631
     "world_worldborders"."pop2005", "world_worldborders"."fips", "world_worldborders"."iso2",
@@ -638,7 +634,7 @@ of abstraction::
638 634
     "world_worldborders"."mpoly" FROM "world_worldborders"
639 635
     WHERE ST_Intersects("world_worldborders"."mpoly", ST_Transform(%s, 4326))
640 636
     >>> qs # printing evaluates the queryset
641  
-    [<WorldBorders: United States>]
  637
+    [<WorldBorder: United States>]
642 638
 
643 639
 __ http://spatialreference.org/ref/epsg/32140/
644 640
 
@@ -649,7 +645,7 @@ access of the geometry field, GeoDjango creates a `GEOS geometry object <ref-geo
649 645
 exposing powerful functionality, such as serialization properties for
650 646
 popular geospatial formats::
651 647
 
652  
-    >>> sm = WorldBorders.objects.get(name='San Marino')
  648
+    >>> sm = WorldBorder.objects.get(name='San Marino')
653 649
     >>> sm.mpoly
654 650
     <MultiPolygon object at 0x24c6798>
655 651
     >>> sm.mpoly.wkt # WKT
@@ -694,9 +690,9 @@ Let's dive in again -- create a file called ``admin.py`` inside the
694 690
 ``world`` application, and insert the following::
695 691
 
696 692
     from django.contrib.gis import admin
697  
-    from models import WorldBorders
  693
+    from models import WorldBorder
698 694
 
699  
-    admin.site.register(WorldBorders, admin.GeoModelAdmin)
  695
+    admin.site.register(WorldBorder, admin.GeoModelAdmin)
700 696
 
701 697
 Next, edit your ``urls.py`` in the ``geodjango`` project folder to look
702 698
 as follows::
@@ -715,7 +711,7 @@ Start up the Django development server::
715 711
     $ python manage.py runserver
716 712
 
717 713
 Finally, browse to ``http://localhost:8000/admin/``, and log in with the admin
718  
-user created after running ``syncdb``.  Browse to any of the ``WorldBorders``
  714
+user created after running ``syncdb``.  Browse to any of the ``WorldBorder``
719 715
 entries -- the borders may be edited by clicking on a polygon and dragging
720 716
 the vertexes to the desired position.
721 717
 
@@ -747,7 +743,7 @@ First, there are some important requirements and limitations:
747 743
 If you meet these requirements, then just substitute in the ``OSMGeoAdmin``
748 744
 option class in your ``admin.py`` file::
749 745
 
750  
-    admin.site.register(WorldBorders, admin.OSMGeoAdmin)
  746
+    admin.site.register(WorldBorder, admin.OSMGeoAdmin)
751 747
 
752 748
 .. rubric:: Footnotes
753 749
 

0 notes on commit ccbca7a

Please sign in to comment.
Something went wrong with that request. Please try again.