django http response code example
Example 1: httpresponse django
from django.http import HttpResponse
Example 2: set http response content type django
reponse = HttpResponse(content)
response['Content-Type'] = 'application/json'
reponse = HttpResponse(content, content_type:'application/json')
Example 3: import http response in django
from django.http import HttpResponse
import datetime
def current_datetime(request):
now = datetime.datetime.now()
html = "<html><body>It is now %s.</body></html>" % now
return HttpResponse(html)