Skip to content Skip to sidebar Skip to footer

Django Is Showing A Method Object Is Not Subscriptable When Submitting Email

I have a website and I would like to allow users to contact us. Thus, when I click on the submit button I am getting the error 'method' object is not subscriptable Bellow is the e

Solution 1:

The problem are the following lines:

mail=request.POST.get['email']
        subject=request.POST.get['objet']
        msg=request.POST.get['message']

.get is a method and not a list and should therefore be called like this:

mail=request.POST.get('email')
        subject=request.POST.get('objet')
        msg=request.POST.get('message')

Solution 2:

The error is because of the Square brackets in request.POST.get['email']. Just Replace the square brackets with the () brackets. The same can be accessed using request.data.get('email')

Hope it will help you.

Post a Comment for "Django Is Showing A Method Object Is Not Subscriptable When Submitting Email"