1
0
mirror of https://github.com/django/django.git synced 2024-12-23 09:36:06 +00:00
django/tests/gis_tests/relatedapp/models.py
Tim Graham 890537253c Made runtests.py run gis_tests only when using a GIS database backend.
This facilitates other changes like refs #28160.
2017-05-04 20:29:19 -04:00

65 lines
1.6 KiB
Python

from django.contrib.gis.db import models
class SimpleModel(models.Model):
class Meta:
abstract = True
class Location(SimpleModel):
point = models.PointField()
def __str__(self):
return self.point.wkt
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 AugmentedLocation(Location):
extra_text = models.TextField(blank=True)
class DirectoryEntry(SimpleModel):
listing_text = models.CharField(max_length=50)
location = models.ForeignKey(AugmentedLocation, models.CASCADE)
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 Author(SimpleModel):
name = models.CharField(max_length=100)
dob = models.DateField()
class Article(SimpleModel):
title = models.CharField(max_length=100)
author = models.ForeignKey(Author, models.CASCADE, unique=True)
class Book(SimpleModel):
title = models.CharField(max_length=100)
author = models.ForeignKey(Author, models.SET_NULL, related_name='books', null=True)
class Event(SimpleModel):
name = models.CharField(max_length=100)
when = models.DateTimeField()