class City(SimpleModel): name = models.CharField(max_length=50) state = models.CharField(max_length=2) location = models.ForeignKey(Location, models.CASCADE) def __str__(self): return self.name
class OracleGeometryColumns(models.Model): "Maps to the Oracle USER_SDO_GEOM_METADATA table." table_name = models.CharField(max_length=32) column_name = models.CharField(max_length=1024) srid = models.IntegerField(primary_key=True) # TODO: Add support for `diminfo` column (type MDSYS.SDO_DIM_ARRAY). class Meta: app_label = 'gis' db_table = 'USER_SDO_GEOM_METADATA' managed = False @classmethod def table_name_col(cls): """ Return the name of the metadata column used to store the feature table name. """ return 'table_name' @classmethod def geom_col_name(cls): """ Return the name of the metadata column used to store the feature geometry column. """ return 'column_name' def __str__(self): return '%s - %s (SRID: %s)' % (self.table_name, self.column_name, self.srid)
class UniqueTogetherModel(models.Model): city = models.CharField(max_length=30) point = models.PointField() class Meta: unique_together = ('city', 'point') required_db_features = ['supports_geometry_field_unique_index']
class NamedModel(models.Model): name = models.CharField(max_length=30) class Meta: abstract = True def __str__(self): return self.name
class City(models.Model): name = models.CharField(max_length=30) point = models.PointField() class Meta: app_label = 'geoadmin' def __str__(self): return self.name
class County(NamedModel): state = models.CharField(max_length=20) mpoly = models.MultiPolygonField(geography=True) class Meta: app_label = 'geogapp' def __str__(self): return ' County, '.join([self.name, self.state])
class OracleSpatialRefSys(models.Model, SpatialRefSysMixin): "Maps to the Oracle MDSYS.CS_SRS table." cs_name = models.CharField(max_length=68) srid = models.IntegerField(primary_key=True) auth_srid = models.IntegerField() auth_name = models.CharField(max_length=256) wktext = models.CharField(max_length=2046) # Optional geometry representing the bounds of this coordinate # system. By default, all are NULL in the table. cs_bounds = models.PolygonField(null=True) class Meta: app_label = 'gis' db_table = 'CS_SRS' managed = False @property def wkt(self): return self.wktext
class City(NamedModel): name_txt = models.TextField(default='') name_short = models.CharField(max_length=5) population = models.IntegerField() density = models.DecimalField(max_digits=7, decimal_places=1) dt = models.DateField() point = models.PointField() class Meta: app_label = 'layermap'
class Parcel(SimpleModel): name = models.CharField(max_length=30) city = models.ForeignKey(City, models.CASCADE) center1 = models.PointField() # Throwing a curveball w/`db_column` here. center2 = models.PointField(srid=2276, db_column='mycenter') border1 = models.PolygonField() border2 = models.PolygonField(srid=2276) def __str__(self): return self.name
class Event(SimpleModel): name = models.CharField(max_length=100) when = models.DateTimeField()
class Book(SimpleModel): title = models.CharField(max_length=100) author = models.ForeignKey(Author, models.SET_NULL, related_name='books', null=True)
class Article(SimpleModel): title = models.CharField(max_length=100) author = models.ForeignKey(Author, models.CASCADE, unique=True)
class Author(SimpleModel): name = models.CharField(max_length=100) dob = models.DateField()
class DirectoryEntry(SimpleModel): listing_text = models.CharField(max_length=50) location = models.ForeignKey(AugmentedLocation, models.CASCADE)
class PennsylvaniaCity(City): county = models.CharField(max_length=30) founded = models.DateTimeField(null=True) class Meta: app_label = 'geoapp'
from djmodels.contrib.gis.db import models from djmodels.db import connection, migrations ops = [ migrations.CreateModel( name='Neighborhood', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('name', models.CharField(max_length=100, unique=True)), ('geom', models.MultiPolygonField(srid=4326)), ], options={ }, bases=(models.Model,), ), migrations.CreateModel( name='Household', fields=[ ('id', models.AutoField(verbose_name='ID', serialize=False, auto_created=True, primary_key=True)), ('neighborhood', models.ForeignKey( 'gis_migrations.Neighborhood', models.SET_NULL, to_field='id', null=True, )), ('address', models.CharField(max_length=100)), ('zip_code', models.IntegerField(null=True, blank=True)), ('geom', models.PointField(srid=4326, geography=True)), ], options={ },
class Zipcode(NamedModel): code = models.CharField(max_length=10) poly = models.PolygonField(geography=True)