Django 2.1.x Documentationapplication/ xhtml+xml: from django.shortcuts import render def my_view(request): # View code here... return render(request, 'myapp/index.html', { 'foo': 'bar', }, content_type='application/xhtml+xml') ex.html') c = {'foo': 'bar'} return HttpResponse(t.render(c, request), content_type='application/xhtml+xml') render_to_response() render_to_response(template_name, context=None, content_type=None, status=None the serialization will fail with a ValueError exception. Read also the W3C’s explanation of HTML, XHTML, XML and Control Codes. JSON When staying with the same example data as before it would be serialized0 码力 | 1910 页 | 6.49 MB | 1 年前3
Django 2.1.x DocumentationExample The following example renders the template myapp/index.html with the MIME type application/xhtml+xml: from django.shortcuts import render def my_view(request): # View code here... return return render(request, 'myapp/index.html', { 'foo': 'bar', }, content_type='application/xhtml+xml') This example is equivalent to: from django.http import HttpResponse from django.template import html') c = {'foo': 'bar'} return HttpResponse(t.render(c, request), content_type='application/xhtml+xml') render_to_response() render_to_response(template_name, context=None, content_type=None, status=None0 码力 | 2790 页 | 2.71 MB | 1 年前3
Django 2.2.x DocumentationExample The following example renders the template myapp/index.html with the MIME type application/xhtml+xml: from django.shortcuts import render def my_view(request): # View code here... return return render(request, 'myapp/index.html', { 'foo': 'bar', }, content_type='application/xhtml+xml') This example is equivalent to: from django.http import HttpResponse from django.template import html') c = {'foo': 'bar'} return HttpResponse(t.render(c, request), content_type='application/xhtml+xml') render_to_response() render_to_response(template_name, context=None, content_type=None, status=None0 码力 | 2915 页 | 2.83 MB | 1 年前3
Django 5.1 DocumentationExample The following example renders the template myapp/index.html with the MIME type application/xhtml+xml: from django.shortcuts import render def my_view(request): # View code here... return "myapp/index.html", { "foo": "bar", }, content_type="application/xhtml+xml", ) This example is equivalent to: from django.http import HttpResponse from django.template html") c = {"foo": "bar"} return HttpResponse(t.render(c, request), content_type="application/xhtml+xml") redirect() redirect(to, *args, permanent=False, **kwargs)[source] [https://github.com/dja0 码力 | 3513 页 | 3.17 MB | 1 年前3
Django 5.1.2 DocumentationExample The following example renders the template myapp/index.html with the MIME type application/xhtml+xml: from django.shortcuts import render def my_view(request): # View code here... return "myapp/index.html", { "foo": "bar", }, content_type="application/xhtml+xml", ) This example is equivalent to: from django.http import HttpResponse from django.template html") c = {"foo": "bar"} return HttpResponse(t.render(c, request), content_type="application/xhtml+xml") redirect() redirect(to, *args, permanent=False, **kwargs)[source] [https://github.com/dja0 码力 | 3519 页 | 3.17 MB | 1 年前3
Django 5.0.x DocumentationExample The following example renders the template myapp/index.html with the MIME type application/xhtml+xml: from django.shortcuts import render def my_view(request): # View code here... return "myapp/index.html", { "foo": "bar", }, content_type="application/xhtml+xml", ) This example is equivalent to: from django.http import HttpResponse from django.template html") c = {"foo": "bar"} return HttpResponse(t.render(c, request), content_type="application/xhtml+xml") redirect() redirect(to, *args, permanent=False, **kwargs) Returns an HttpResponseRedirect0 码力 | 3407 页 | 3.21 MB | 1 年前3
Django 2.2.x DocumentationExample The following example renders the template myapp/index.html with the MIME type application/xhtml+xml: from django.shortcuts import render def my_view(request): # View code here... return render(request 29.dev20220411083753 (continued from previous page) 'foo': 'bar', }, content_type='application/xhtml+xml') This example is equivalent to: from django.http import HttpResponse from django.template import ex.html') c = {'foo': 'bar'} return HttpResponse(t.render(c, request), content_type='application/xhtml+xml') render_to_response() render_to_response(template_name, context=None, content_type=None, status=None0 码力 | 2060 页 | 7.23 MB | 1 年前3
Django 2.0.x DocumentationExample The following example renders the template myapp/index.html with the MIME type application/ xhtml+xml: 206 Chapter 3. Using Django Django Documentation, Release 2.0.14.dev20190701080343 from django here... return render(request, 'myapp/index.html', { 'foo': 'bar', }, content_type='application/xhtml+xml') This example is equivalent to: from django.http import HttpResponse from django.template import ex.html') c = {'foo': 'bar'} return HttpResponse(t.render(c, request), content_type='application/xhtml+xml') render_to_response() render_to_response(template_name, context=None, content_type=None, status=None0 码力 | 1880 页 | 6.41 MB | 1 年前3
Django 2.0.x DocumentationExample The following example renders the template myapp/index.html with the MIME type application/xhtml+xml: from django.shortcuts import render def my_view(request): # View code here... return return render(request, 'myapp/index.html', { 'foo': 'bar', }, content_type='application/xhtml+xml') This example is equivalent to: from django.http import HttpResponse from django.template import html') c = {'foo': 'bar'} return HttpResponse(t.render(c, request), content_type='application/xhtml+xml') render_to_response() render_to_response(template_name, context=None, content_type=None, status=None0 码力 | 2746 页 | 2.67 MB | 1 年前3
Django 3.0.x DocumentationExample The following example renders the template myapp/index.html with the MIME type application/xhtml+xml: from django.shortcuts import render def my_view(request): # View code here... return return render(request, 'myapp/index.html', { 'foo': 'bar', }, content_type='application/xhtml+xml') This example is equivalent to: from django.http import HttpResponse from django.template import html') c = {'foo': 'bar'} return HttpResponse(t.render(c, request), content_type='application/xhtml+xml') redirect() redirect(to, *args, permanent=False, **kwargs) Returns an HttpResponseRedirect0 码力 | 3085 页 | 2.95 MB | 1 年前3
共 30 条
- 1
- 2
- 3













