I want to calculate how many relativedelta() there are between two date objects. My code is below, it's not working though as a relative delata cannot divide a date, but maybe it shows what I'm trying to do.
For example, if my relative delta is one week relativedelta(weeks=1) and my dates are 2022-05-01 and 2022-05-15 then two of the 1 week deltas will fit into the two dates that are two weeks apart.
delta=relativedelta(days= self.cleaned_data['delta_days'], months=self.cleaned_data['delta_months'])
no_loops = (self.cleaned_data['to_date'] - self.cleaned_data['from_date']) / delta
if no_loops > 36: raise ValidationError('Too many iterations.')