ErrorDict' object has no attribute 'status_code

Hello World!

I got this error from when I submit a post method, and here is my post code.
I can not have an exact traceback to know the error well,
any help please

def post(self, request, *args, **kwargs):
form = self.form_class(request.POST)
context = {
‘form’: form,
}
if form.is_valid():
print(‘yeeeeeeees’)
clt = form.save(commit=False)
clt.creator = request.user
clt.number = autoNumInvoice()
clt.save()
return render(‘clients:home’)
else:
return form.errors
return render(request, self.template_name, context=context)

A view must return an HTTP response, not the errors dict from your form.

Also, when posting code, please enclose the code between lines consisting of only three backtick - ` characters. This means you’ll have one line of ```, followed by your lines of code, followed by another line of ```. This allows your code to maintain its formatting, which is extremely important when working with Python!

1 Like

thank you Ken, i want just know why my form is not valid, is there any way to know the exact traceback

Review the Working with forms docs, particularly the parts on Rendering form error messages.

1 Like