Now that Django supports the DateRangeField, is there a 'Pythonic' way to prevent records from having overlapping date ranges?
# Hypothetical use case
One hypothetical use case would be a booking system, where you don't want people to book the same resource at the same time.
# Hypothetical example code
<!-- language: lang-py -->
class Booking(models.model):
# The resource to be reserved
resource = models.ForeignKey('Resource')
# When to reserve the resource
date_range = models.DateRangeField()
class Meta:
unique_together = ('resource', 'date_range',)
This might have the effect of adding an exclusion constraint on the underlying table:
https://www.postgresql.org/docs/9.3/static/sql-createtable.html#SQL-CREATETABLE-EXCLUDE
--
Sent from my Android device with K-9 Mail. Please excuse my brevity.