1๐
โ
So what you are saying is you need to return two things (an HttpResponse and the status value) from your google
function instead of just one thing.
In this case you should return a tuple, eg:
def google(request, objectId):
google = {}
google['status'] = 1
response = HttpResponse(json.dumps(google)) # <-- should be string not dict
return response, google
def process_view(request):
dspAction = {}
try:
response, google = google(request, objectId)
if google['status'] == int(1):
#some function
except:
dspAction['Google Status'] = "Google Action Completed"
return HttpResponse(json.dumps(dspAction),content_type='application/json')
๐คAnentropic
0๐
return HttpResponse(google.status)
EDIT from comment:
To use the other attributes in the dictionary you need to pass the context variables, usually with render.
# view.py
from django.shortcuts import render
...
return render(request, "template.html", {'google':google})
# template.html
# you can then access the different attributes of the dict
{{ google }} {{ google.status }} {{ google.error }}
๐คawwester
- [Answer]-How to use models associated with a user in Django when rendering an HTML page
- [Answer]-Heroku deployment busted, operational error
- [Answer]-CSS didn't work after migration of django website into another instance
Source:stackexchange.com