Hi everyone, I've been playing with Django for a couple of days and stumbled upon the following issue. I have the following models:
Employee = (id, employeeName)
Project = (id, projectName)
Assignment = (fk_employee, fk_project, from_date, to_date)
What I want to do is to create a validator that won't allow assignment periods to overlap. The algorithm is very simple, but I don't know how to properly set it using validators.
What I thought is to have something like:
class Assignment(models.Model):
...
from_date = models.DateField(
validators=[DateInRangeValidator(%theFromDateValue%, %aReferenceToTheEmployee%)])
to_date = models.DateField(
validators=[DateInRangeValidator(%theToDateValue%, %aReferenceToTheEmployee%)])
def DateInRangeValidator(dateValue, employee):
...
BTW, I wrote these %theDateValue% and %aReferenceToTheEmployee% because I don't know how to send those parameters. Would it be 'self', 'from_date' or something else?
So, am I close to the solution? Thanks in advance! :)