if selected_date.month == 12:
    last_day_selected_month = date(selected_date.year, selected_date.month, 31)
else:
    last_day_selected_month = date(selected_date.year, selected_date.month +
        1, 1) - timedelta(days=1)
python's datetime and end of the month