PageRenderTime 142ms CodeModel.GetById 60ms app.highlight 6ms RepoModel.GetById 75ms 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
 1from django.contrib.gis.db import models
 2from django.contrib.localflavor.us.models import USStateField
 3
 4class Location(models.Model):
 5    point = models.PointField()
 6    objects = models.GeoManager()
 7    def __unicode__(self): return self.point.wkt
 8
 9class City(models.Model):
10    name = models.CharField(max_length=50)
11    state = USStateField()
12    location = models.ForeignKey(Location)
13    objects = models.GeoManager()
14    def __unicode__(self): return self.name
15
16class AugmentedLocation(Location):
17    extra_text = models.TextField(blank=True)
18    objects = models.GeoManager()
19    
20class DirectoryEntry(models.Model):
21    listing_text = models.CharField(max_length=50)
22    location = models.ForeignKey(AugmentedLocation)
23    objects = models.GeoManager()
24
25class Parcel(models.Model):
26    name = models.CharField(max_length=30)
27    city = models.ForeignKey(City)
28    center1 = models.PointField()
29    # Throwing a curveball w/`db_column` here.
30    center2 = models.PointField(srid=2276, db_column='mycenter') 
31    border1 = models.PolygonField()
32    border2 = models.PolygonField(srid=2276)
33    objects = models.GeoManager()
34    def __unicode__(self): return self.name
35
36# These use the GeoManager but do not have any geographic fields.
37class Author(models.Model):
38    name = models.CharField(max_length=100)
39    objects = models.GeoManager()
40
41class Article(models.Model):
42    title = models.CharField(max_length=100)
43    author = models.ForeignKey(Author, unique=True)
44    objects = models.GeoManager()
45
46class Book(models.Model):
47    title = models.CharField(max_length=100)
48    author = models.ForeignKey(Author, related_name='books', null=True)
49    objects = models.GeoManager()