2
simple approach is to render first the data from your template to string and response it as json like the sample code below.
from django.template.loader import render_to_string
from django.http import HttpResponse
def jsonview(request):
context = {}
context['data'] = render_to_string("json.html", {'date': datetime.now()})
return HttpResponse(json.dumps(context), content_type="application/json")
0
You should use Django templatetags. You can create your own custom template tag or use built-in ones
In this case you could use templatetag now
in your json.html file:
{% now "SHORT_DATETIME_FORMAT" %}
- [Answered ]-Django downloading a csv file with variable in name
- [Answered ]-System check identified 3 issues (0 silenced)
Source:stackexchange.com