1. from django.contrib.gis.db import models
    
  2. 
    
  3. 
    
  4. class NamedModel(models.Model):
    
  5.     name = models.CharField(max_length=30)
    
  6. 
    
  7.     class Meta:
    
  8.         abstract = True
    
  9. 
    
  10.     def __str__(self):
    
  11.         return self.name
    
  12. 
    
  13. 
    
  14. class City(NamedModel):
    
  15.     point = models.PointField(geography=True)
    
  16. 
    
  17.     class Meta:
    
  18.         app_label = "geogapp"
    
  19. 
    
  20. 
    
  21. class Zipcode(NamedModel):
    
  22.     code = models.CharField(max_length=10)
    
  23.     poly = models.PolygonField(geography=True)
    
  24. 
    
  25. 
    
  26. class County(NamedModel):
    
  27.     state = models.CharField(max_length=20)
    
  28.     mpoly = models.MultiPolygonField(geography=True)
    
  29. 
    
  30.     class Meta:
    
  31.         app_label = "geogapp"
    
  32. 
    
  33.     def __str__(self):
    
  34.         return " County, ".join([self.name, self.state])