from django.db import models # Create your models here. from django.contrib.auth.models import User class Track(models.Model): user = models.ForeignKey(User, blank=False) start = models.DateTimeField() name = models.CharField(max_length=1024, blank=False) description = models.TextField(blank=True) @property def finish(self): return self.segment_set.order_by("-time")[0].finish class Segment(models.Model): track = models.ForeignKey(Track) time = models.DateTimeField() number = models.IntegerField(default=1) @property def finish(self): return self.point_set.order_by("-time")[0].time class Point(models.Model): time = models.DateTimeField() latitude = models.DecimalField(max_digits=13, decimal_places=10) longitude = models.DecimalField(max_digits=12, decimal_places=10) elevation = models.DecimalField(max_digits=20, decimal_places=2) segment = models.ForeignKey(Segment)