I have the model Period as below:
class Period(models.Model):
number = models.PositiveIntegerField(primary_key=True)
start_time = models.TimeField()
end_time = models.TimeField()
How can I add constraints to make Period.start_time < Period.end_time and Period models have the order like this?
Period 1: 7:00-7:50; Period 2: 7:50-8:40; ...
The field number express the order of the period instance. My approach is adding methods to check if it is valid . However, I want to know that there is any database way to do this.