summaryrefslogtreecommitdiff
path: root/app/locations
diff options
context:
space:
mode:
Diffstat (limited to 'app/locations')
-rw-r--r--app/locations/models.py19
1 files changed, 4 insertions, 15 deletions
diff --git a/app/locations/models.py b/app/locations/models.py
index 1baa964..e9c79e5 100644
--- a/app/locations/models.py
+++ b/app/locations/models.py
@@ -15,13 +15,10 @@ class Region(models.Model):
name = models.CharField(max_length=50)
slug = models.SlugField()
pub_date = models.DateTimeField('Date published', null=True)
- # GeoDjango specific Polygon Field and GeoManager
geometry = models.MultiPolygonField(srid=4326, null=True)
lon = models.FloatField('Longitude', help_text="Longitude of centerpoint", null=True)
lat = models.FloatField('Latitude', help_text="Latitude of centerpoint", null=True)
zoom_level = models.CharField(max_length=2, null=True)
- # GeoManager, a subclass that adds a rich set of geospatial queryset methods
- objects = models.GeoManager()
def get_absolute_url(self):
return "/locations/region/%s/" % (self.slug)
@@ -81,10 +78,9 @@ class Country(models.Model):
zoom_level = models.CharField(max_length=2, null=True)
slug = models.SlugField(null=True)
visited = models.BooleanField(default=False)
- lux_region = models.ForeignKey(Region, null=True)
+ lux_region = models.ForeignKey(Region, on_delete=models.CASCADE, null=True)
pub_date = models.DateTimeField('Date published', null=True)
geometry = models.MultiPolygonField('Country Border', srid=4326)
- objects = models.GeoManager()
class Meta:
ordering = ['name']
@@ -100,12 +96,11 @@ class Country(models.Model):
class State(models.Model):
"""Model to hold state boundaries"""
name = models.CharField(max_length=250, blank=True, null=True,)
- country = models.ForeignKey(Country)
+ country = models.ForeignKey(Country, on_delete=models.CASCADE)
slug = models.SlugField()
code = models.CharField(max_length=2, null=True, blank=True)
pub_date = models.DateTimeField('Date published', null=True)
geometry = models.MultiPolygonField(srid=4326, null=True)
- objects = models.GeoManager()
class Meta:
ordering = ['name']
@@ -119,14 +114,11 @@ class State(models.Model):
class Location(models.Model):
"""Model to hold location shapes as arbitrarily defined by me"""
- state = models.ForeignKey(State)
+ state = models.ForeignKey(State, on_delete=models.CASCADE)
name = models.CharField(max_length=50, )
slug = models.SlugField()
pub_date = models.DateTimeField('Date published', null=True)
- # GeoDjango specific Polygon Field and GeoManager
geometry = models.MultiPolygonField(srid=4326)
- # GeoManager, a subclass that adds a rich set of geospatial queryset methods
- objects = models.GeoManager()
def __str__(self):
return self.name
@@ -148,10 +140,7 @@ class Route(models.Model):
zoom = models.CharField(max_length=2, null=True)
template_var_name = models.CharField(max_length=10, null=True)
pub_date = models.DateTimeField('Date published', null=True)
- # GeoDjango specific Polygon Field and GeoManager
geometry = models.MultiPointField(srid=4326)
- # GeoManager, a subclass that adds a rich set of geospatial queryset methods
- objects = models.GeoManager()
def get_absolute_url(self):
return "/locations/%s/%s/%s/" % (self.slug)
@@ -162,7 +151,7 @@ class Route(models.Model):
class CheckIn(models.Model):
point = models.PointField(blank=True)
- location = models.ForeignKey(Location, blank=True, null=True)
+ location = models.ForeignKey(Location, on_delete=models.CASCADE, blank=True, null=True)
date = models.DateField(default=timezone.now)
class Meta: