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

20👍

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:

@render_to("lender/main_views/home.html")
def home(request):
    form = LeadSubmissionForm(request.POST or None)
    if request.method == 'POST':
        if form.is_valid():
            form.save()
            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