Q:

'view' didn't return an HttpResponse object. It returned None instead.` - class based view

I am trying to access the posted form values in a class based Django view (UpdateView). I have it nearly working, but I am getting the error:
The view maintenance.views.maintenanceEdit didn't return an HttpResponse object. It returned None instead.
I have found many other posts having the same problem with a function based view, which return render(request, 'template.html') fixes the problem, but how can I do the same thing with a class based view?
my views.py:
class maintenanceEdit(LoginRequiredMixin,UpdateView,):
    model = Maintenance
    form_class = EditMaintenance
    template_name = 'maintenance_edit.html'
    login_url = 'login'

    def form_valid(self, form,):
        instance = form.save(commit=False)
        complete = form.instance.completed
        super(maintenanceEdit, self).form_valid(form)

In my models.py I have:
    def get_absolute_url(self):
        return reverse('equipmentdashboard',)

Which brings the user back to the correct page when the form is submitted. But now this is not working...

A:

You forgot to return the result from the super() call:
from django.urls import reverse_lazy

class maintenanceEdit(LoginRequiredMixin,UpdateView,):
    model = Maintenance
    form_class = EditMaintenance
    template_name = 'maintenance_edit.html'
    login_url = 'login'
    success_url = reverse_lazy('equipmentdashboard')

    def form_valid(self, form,):
        instance = form.save(commit=False)
        complete = form.instance.completed
        return super(maintenanceEdit, self).form_valid(form)
That being said, Django will in case of a succesful POST return a redirect, to implement the Post/Redirect/Get pattern [wiki]. You thus should specify a success_url [Django-doc].
Making an override like the one here is not useful, since you retrieve the .completed attribute, but you do nothing with this.

