Error occurred while clicked on empty search bar
AniketP88 opened this issue · 0 comments
AniketP88 commented
In views.py
try except concept can be implemented to fix a bug
def word(request):
try:
search = request.GET.get('search')
except:
search = None
if search:
dictionary = PyDictionary()
meaning = dictionary.meaning(search)
synonyms = dictionary.synonym(search)
antonyms = dictionary.antonym(search)
context = {
'meaning': meaning['Noun'][0],
'synonyms': synonyms,
'antonyms': antonyms
}
return render(request, 'word.html', context)
else:
return render(request, 'word.html',context={})