requestpost does not read form data in django

A MultiValueDictKeyError comes when you try to access something from request.POST which doesn’t exist. It’s basically the same the python KeyError. Use request.POST.get('key', 'default_if_key_doesn't exist')

def create(request): 
    if request.POST: 
        body = request.POST.get('note', '')
        title = request.POST('title', '')

        print(f'title = { title }\nbody = { body }'

CLICK HERE to find out more related problems solutions.

Leave a Comment

Your email address will not be published.

Scroll to Top