how to return a 400 errro_message in pyramid
Question
I want to return the format:
res['result'] == False
and res['error_message'] == 'Unknown User'
How to do it in views.py
?
Solution
Are you trying to return a JSON response? In that case set your renderer as json
and return a dict containing the values you want.
def myview(request):
return {'result': False, 'error_message': 'Unknown User'}
config.add_view(myview, renderer='json')
Obviously you'll need to add other stuff for your specific view/route combination, but this is all covered in the Pyramid documentation
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow