get method in django 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' # or application/text, etc.
# one-line usage
reponse = HttpResponse(content, content_type:'application/json')
Example 3: django require_POST body
# body -> {"name":"foo", "surname":"bar}
def my_view(request):
print(request.POST) # print the QueryDict object
print(request.POST.get('name') # print foo