models.py
class Completion(models.Model):
start_date = models.DateField()
end_date = models.DateField()
batch = models.ForeignKey(Batch)
topic = models.ForeignKey(Topic)
In above code DateField()
generates a date selecting widget in admin site where you can select proper date or enter it manually in a textbox. The problems are:
How do I restrict the user to select a Date that comes under year 2000 to 2100.
when user manually types a date in the text-box, it accepts any date that's in format yy-mm-dd. I need validation so non existing date should not be entered.
Check out validators!
First, define your validator:
Now you can use it in your model field:
And also in a form field:
More details in the docs, linked to above.