[Fixed]-Data is not inserting in database when I click submit button

1👍

here is the answer, we need to use the request.POST

def home(request):
    if request.method == 'POST':
        form = UserInformationForm(request.POST)
        form.save()
        return HttpResponseRedirect('/home/')
    else:
        form = UserInformationForm()
        variables =  { 'form': form, 'user': request.user }

    return render(request,'home.html',variables)

0👍

the first: you need add urls.py to you app
the second: you need to change your views.py to lool like this

`
    info = UserInformation()
    lastName = request.POST.get('lastName')
    ...
    info.save()
`

Leave a comment