Reputation: 2750
I want to return the format:
res['result'] == False
and res['error_message'] == 'Unknown User'
How to do it in views.py
?
Upvotes: 0
Views: 102
Reputation: 23331
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
Upvotes: 2