[Solved]-Caught AttributeError while rendering: 'WSGIRequest' object has no attribute 'get'


You don’t need to pass in the request when instantiating the LeadSubmissionForm when the request.method == ‘GET’.

To save a few lines of code, you can also do:

def home(request):
    form = LeadSubmissionForm(request.POST or None)
    if request.method == 'POST':
        if form.is_valid():
            return HttpResponseRedirect(reverse("search_results"))
    testimonials = Testimonial.objects.filter(published=True)[:3]
    return {'lead_submission_form':form, 'testimonials': testimonials}

Hope that helps you out.

Leave a comment