Changes between Version 3 and Version 4 of GeoDjangoModelAPI
- Timestamp:
- Oct 8, 2007, 1:27:36 PM (17 years ago)
Legend:
- Unmodified
- Added
- Removed
- Modified
-
GeoDjangoModelAPI
v3 v4 6 6 from django.contrib.gis.db import models 7 7 8 class Zip(models.Model , models.GeoMixin):8 class Zip(models.Model): 9 9 code = models.CharField(maxlength=5) 10 10 poly = models.PolygonField() … … 34 34 * Defaults to True. Creates a GiST index for the given geometry. Update the index with the PostgreSQL command {{{VACUUM ANALYZE}}} (may take a while to execute depending on how large your geographic-enabled tables are). Please note that this is different from the {{{db_index}}} field option since geographic indexes are created in a different manner than regular indexes. 35 35 36 == GeoMixin ==36 == !GeoMixin == 37 37 38 The [http://code.djangoproject.com/browser/django/branches/gis/django/contrib/gis/db/models/GeoMixin.py GeoMixin] is n ecessary for all geographic-enabled models. The mixin providesextra instance methods ([wiki:GeoDjangoDatabaseAPI#ExtraInstanceMethods discussed in the database api docs]) for geographic models without subclassing (aka ModelInheritance) -- which is not yet functional in Django.38 The [http://code.djangoproject.com/browser/django/branches/gis/django/contrib/gis/db/models/GeoMixin.py GeoMixin] is no longer necessary for all geographic-enabled models as of r6467. The mixin used to provide extra instance methods ([wiki:GeoDjangoDatabaseAPI#ExtraInstanceMethods discussed in the database api docs]) for geographic models without subclassing (aka ModelInheritance) -- which is not yet functional in Django. 39 39 40 == GeoManager ==40 == !GeoManager == 41 41 42 42 In order to conduct geographic queries, each geographic model requires {{{GeoManager}}}. This [http://www.djangoproject.com/documentation/model-api/#managers manager] allows for the proper SQL construction for geographic queries; thus, without it, all geographic filters will fail. It should also be noted that a {{{GeoManager}}} will be required even if the model does not have a geographic field itself, ''i.e.'',in the case of a {{{ForeignKey}}} to a geographic model. For example, if we had an {{{Address}}} model with a {{{ForeignKey}}} to our {{{Zip}}} geographic model: