diff options
Diffstat (limited to 'app/birds/models.py')
-rw-r--r-- | app/birds/models.py | 5 |
1 files changed, 4 insertions, 1 deletions
diff --git a/app/birds/models.py b/app/birds/models.py index fc2ce30..380e602 100644 --- a/app/birds/models.py +++ b/app/birds/models.py @@ -89,7 +89,7 @@ class BirdAudio(models.Model): class BirdSighting(models.Model): bird = models.ForeignKey(Bird) - point = models.PointField() + point = models.PointField(blank=True) location = models.ForeignKey(Location, blank=True) date = models.DateTimeField('Date', default=timezone.now) seen_by = models.ManyToManyField(User) @@ -98,6 +98,7 @@ class BirdSighting(models.Model): class Meta: verbose_name_plural = 'Bird Sighting' + get_latest_by = 'date' @property def state(self): @@ -134,6 +135,8 @@ class BirdSighting(models.Model): return self.bird.common_name def save(self): + if not self.point: + self.point = BirdSighting.objects.latest().point try: self.location = Location.objects.filter( geometry__contains=self.point |