Object | Response | Attribute |
---|---|---|
HttpResponse | HTTP-Response | - |
None | HTTP-response | - |
int | HTTP-response | status code |
bool | JSON-response | content |
str | HTTP-response | content |
str ending with '.html' | HTTP-response | template name |
float | HTTP-response | content |
dict | JSON-response | content |
list | JSON-response | content |
Geometry | GeoJSON-response | content |
ValuesQuerySet | JSON-response | content |
QuerySet | JSON-response | content |
RelatedManager | JSON-response | content |
Model Instance | JSON-response | content |
file | File-response | content |
generator | JSON-response | content |
iterator | JSON-response | content |
Any other object | HTTP-response | content |
def view(request):
return 401
def view(request):
return 401, 'Not authorized'
def view(request):
return {'foo': 'bar'}
def view(request):
return SomeModel.objects.all()
def view(request):
return SomeModel.objects.get(pk=1)
def view(request):
return SomeModel.objects.values()
def view(request):
return "template_name.html"
def view(request):
return "template_name.html", {'foo': 'bar'}
def view(request):
return 401, "template_name.html", {'foo': 'bar'}
The example above is the only case that view can return a tuple with 3 elements.