Example 1


class DivergentResponse(models.Model):
    divergent_set = models.ForeignKey(DivergentResponseSet, on_delete=models.CASCADE)
    response_1 = models.CharField(max_length=50)
    response_2 = models.CharField(max_length=50)
    response_3 = models.CharField(max_length=50)
    response_4 = models.CharField(max_length=50)
    response_5 = models.CharField(max_length=50)
    time_1 = models.DurationField()
    time_2 = models.DurationField()
    time_3 = models.DurationField()
    time_4 = models.DurationField()
    time_5 = models.DurationField()
    total_time = models.DurationField()
    stimulus = models.ForeignKey(Stimulus, on_delete=models.PROTECT, null=True, blank=True)

Example 2


class Route(models.Model):
    RouteId = models.AutoField(primary_key=True, default=0)
    Destination1 = models.ForeignKey("MumbaiLocation", related_name = "Destination1")
    Destination2 = models.ForeignKey("MumbaiLocation", related_name = "Destination2")
    Slot11 = models.DurationField(default="00:30:00")
    Slot21 = models.DurationField(default="00:30:00")
    Slot31 = models.DurationField(default="00:30:00")
    Slot41 = models.DurationField(default="00:30:00")
    Slot51 = models.DurationField(default="00:30:00")
    Slot12 = models.DurationField(default="00:30:00")
    Slot22 = models.DurationField(default="00:30:00")
    Slot32 = models.DurationField(default="00:30:00")
    Slot42 = models.DurationField(default="00:30:00")
    Slot52 = models.DurationField(default="00:30:00")

    def __str__(self):
        return str(self.Destination1) + "-" + str(self.Destination2)

Example 3


class Days(models.Model):

    monday              = models.DurationField(default=timedelta())
    tuesday             = models.DurationField(default=timedelta())
    wednesday           = models.DurationField(default=timedelta())
    thursday            = models.DurationField(default=timedelta())
    friday              = models.DurationField(default=timedelta())
    saturday            = models.DurationField(default=timedelta())
    sunday              = models.DurationField(default=timedelta())

    user                = models.ForeignKey(User)

    def __unicode__(self):
        return self.user


Example 4


class Session(models.Model):
    user = models.ForeignKey(User, related_name="sessions", on_delete=models.CASCADE)
    potential = models.DecimalField(max_digits=10, decimal_places=2, default=0)
    actual = models.DecimalField(max_digits=10, decimal_places=2, default=0)
    start = models.DateTimeField(default=None, blank=True, null=True)
    end = models.DateTimeField(default=None, blank=True, null=True)
    est_duration = models.DurationField(default=timedelta())
    time_bonus = models.DurationField(default=timedelta())
    time_challenge = models.DurationField(default=timedelta())
    act_duration = models.DurationField(default=timedelta())
    on_time = models.BooleanField(default=False)

Example 5


class UserActions(models.Model):
    """ save urls called by users """
    user = models.ForeignKey(User, on_delete=models.CASCADE)
    url = models.CharField(max_length=300, null=False)
    method = models.CharField(max_length=4, null=False)
    timestamp = models.DateTimeField(default=timezone.now, null=False)
    duration = models.DurationField(null=False)

Example 6


class Perfo(models.Model):
    Refparcours = models.ForeignKey(BikeTour, blank=True, null=True, on_delete=models.CASCADE)
           # on_delete=models.CASCADE : Perfo effacée si BikeTour effacé !
           # blank=True, null=True : autorisé pour permettre importation de tours sans référence Refparcours
    Date = models.DateField(default=None)    
    Distance = models.FloatField(default=None)
    Temps = models.DurationField(default=None)
    Remarques = models.CharField(max_length=1000, default=None, blank=True, null=True)
    Dénivelé = models.FloatField(default=None, blank=True, null=True)
    Vitesse_max = models.FloatField(default=None, blank=True, null=True)
    FC_moy = models.FloatField(default=None, blank=True, null=True)
    FC_max = models.FloatField(default=None, blank=True, null=True)

English today is not an art to be mastered it's just a tool to use to get a result