The view fitness_app.views.BookingView didn't return an HttpResponse object. It returned None instead

I dont understand as this code was working fine earlier and now i am receiving the above error when the form is submited. views.py file

class BookingView(FormView):
    form_class = AvailabilityForm
    template_name = "availability.html"

    def form_valid(self, form):
        data = form.cleaned_data
        
        bookingList = Appointment.objects.filter()
        for booking in bookingList:
            if booking.start == data["start_time"]:
                print("Cant be booked")
                return HttpResponse("Cant be booked")
            else:
                booking=Appointment.objects.create(
                    name=data["name"], 
                    start=data["start_time"],
                    end=data["end_time"]
                    )
                booking.save()
                return HttpResponse("can be booked")

your queryset is empty so your code never reaches the conditions inside the for loop.

Back to Top