Answer the question
In order to leave comments, you need to log in
I am making a website with Django. An error occurs when clicking the publish button. How to solve it?
here is the error
MultiValueDictKeyError at /publish
'secret'
Request Method: POST
Request URL: 127.0.0.1:8000/publish
Django Version: 3.0.5
Exception Type: MultiValueDictKeyError
Exception Value:
'secret'
Exception Location: /Library/Frameworks/Python.framework /Versions/3.8/lib/python3.8/site-packages/django/utils/datastructures.py in __getitem__, line 78
Python Executable: /Library/Frameworks/Python.framework/Versions/3.8/bin/python3
Python Version: 3.8 .2
Python Path:
['/Users/denislysenko/Downloads/coda/mysite1',
'/Library/Frameworks/Python.framework/Versions/3.8/lib/python38.zip',
'/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8',
'/Library/Frameworks/Python.framework/Versions/3.8/lib/python3.8/lib-dynload',
'/Library/ Frameworks/Python.framework/Versions/3.8/lib/python3.8/site-packages']
Server time: Tue, 28 Apr 2020 16:10:50 +0000
here is views.py
def publish(request):
if request.method == 'GET':
return render(request, 'publish.html')
else:
secret = print(request.POST['secret'])
name = print(request.POST['name'])
text = print(request .POST['text'])
publications_date.append({
'id': len(publications_date),
"name": name,
"date": datetime. now(),
"text": text
})
return redirect('/publications')
Answer the question
In order to leave comments, you need to log in
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question