Complete the code to import the correct class for returning JSON responses in Django.
from django.http import [1]
The JsonResponse class is used to return JSON data in Django views.
Complete the code to return a JSON response with a dictionary containing a message.
def my_view(request): data = {'message': 'Hello, world!'} return [1](data)
Use JsonResponse to return JSON data from a Django view.
Fix the error in the code to correctly return JSON with safe=False for non-dict data.
def my_view(request): data = ['apple', 'banana', 'cherry'] return JsonResponse(data, [1]=False)
The safe parameter must be set to False to allow non-dictionary objects in JsonResponse.
Fill both blanks to create a JSON response with a custom status code and headers.
def my_view(request): data = {'status': 'ok'} return JsonResponse(data, status=[1], headers=[2])
Use status=201 for created response and pass headers as a dictionary.
Fill all three blanks to return a JSON response with a nested dictionary, custom status, and safe=False.
def my_view(request): data = [1] return JsonResponse(data, status=[2], safe=[3])
The data is a dictionary with a list inside, status 202 means accepted, and safe=False allows non-dict if needed.