[Fixed]-Using cleaned_data.get("field") results in AttributError when form is not printed

1👍

Why would you do this in post? Use form_valid method instead:

def form_valid(self, form):
    username = form.cleaned_data.get("username")

    if username:
        print(username)
    return HttpResponseRedirect(self.get_success_url())
👤pythad

Leave a comment