Is there a way to pass JSON objects to the front end of a web template if using the Django framework or Python in general?
For example, if I want to send an object t
Complementing zeekay answer, if you want to send only an object you could do a json dump, for example:
import json
def my_ajax_view(request):
if not request.is_ajax():
raise Http404
data_dict = getmydata() #lets supose is a dict
return HttpResponse(json.dumps(data_dict))
That way you will receive that data via your ajax success and do whatever you want with it.
You can send over lists too, when you receive your response sometimes you will need to do a JSON.parse on data (sometimes cause when you send a dictionary I think is not necessary)