Django: Is there any way to have "unique for date range"?

Posted by tomwolber on Stack Overflow See other posts from Stack Overflow or by tomwolber
Published on 2010-06-02T20:49:59Z Indexed on 2010/06/02 20:54 UTC
Read the original article Hit count: 257

If my model for Items is:

class Item(models.Model):
    name = models.CharField(max_length=500)
    startDate = models.DateField("Start Date", unique="true")
    endDate = models.DateField("End Date")      

Each Item needs to have a unique date range. for example, if i create an Item that has a date range of June 1st to June 8th, how can I keep and Item with a date range of June 3rd to June 5th from being created (or render an error with template logic)?

© Stack Overflow or respective owner

Related posts about python

Related posts about django