PageRenderTime 65ms CodeModel.GetById 14ms RepoModel.GetById 0ms app.codeStats 0ms

/django/contrib/gis/tests/relatedapp/models.py

https://code.google.com/p/mango-py/
Python | 49 lines | 39 code | 8 blank | 2 comment | 0 complexity | 864b71fa5aceed338d11cd0677886f44 MD5 | raw file
Possible License(s): BSD-3-Clause
  1. from django.contrib.gis.db import models
  2. from django.contrib.localflavor.us.models import USStateField
  3. class Location(models.Model):
  4. point = models.PointField()
  5. objects = models.GeoManager()
  6. def __unicode__(self): return self.point.wkt
  7. class City(models.Model):
  8. name = models.CharField(max_length=50)
  9. state = USStateField()
  10. location = models.ForeignKey(Location)
  11. objects = models.GeoManager()
  12. def __unicode__(self): return self.name
  13. class AugmentedLocation(Location):
  14. extra_text = models.TextField(blank=True)
  15. objects = models.GeoManager()
  16. class DirectoryEntry(models.Model):
  17. listing_text = models.CharField(max_length=50)
  18. location = models.ForeignKey(AugmentedLocation)
  19. objects = models.GeoManager()
  20. class Parcel(models.Model):
  21. name = models.CharField(max_length=30)
  22. city = models.ForeignKey(City)
  23. center1 = models.PointField()
  24. # Throwing a curveball w/`db_column` here.
  25. center2 = models.PointField(srid=2276, db_column='mycenter')
  26. border1 = models.PolygonField()
  27. border2 = models.PolygonField(srid=2276)
  28. objects = models.GeoManager()
  29. def __unicode__(self): return self.name
  30. # These use the GeoManager but do not have any geographic fields.
  31. class Author(models.Model):
  32. name = models.CharField(max_length=100)
  33. objects = models.GeoManager()
  34. class Article(models.Model):
  35. title = models.CharField(max_length=100)
  36. author = models.ForeignKey(Author, unique=True)
  37. objects = models.GeoManager()
  38. class Book(models.Model):
  39. title = models.CharField(max_length=100)
  40. author = models.ForeignKey(Author, related_name='books', null=True)
  41. objects = models.GeoManager()