Question

I want to return the format:

res['result'] == False and res['error_message'] == 'Unknown User'

How to do it in views.py?

Was it helpful?

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
scroll top