[Fixed]-Django: TypeError: 'datetime.date' object has no attribute 'get'

1👍

You don’t validate over multiple fields, thus I suggest trying this instead of def clean(self):

def clean_start_date(self):
    st_date = self.cleaned_data.get("start_date")

    if st_date < datetime.date.today():
        raise forms.ValidationError("The date cannot be in the past!")
    return st_date

Edit: If you did try to validate over multiple fields, that would be the case when documentation suggests using custom clean function.

👤mxle

Leave a comment