Python one-day training 103 ---- Django template exercises, pythondjango
Requirements
Request. META is a Python dictionary that contains all the Header information of this HTTP request, such as the user IP address and user Agent. You can obtain this dictionary through request. META. items. You must output the META information to the webpage.
Output result
Source code index.html
Views. py
from django.shortcuts import render# Create your views here.def display_meta(request): values = request.META.items() html = {} html['index_title']='Display META' html['index_text']=values return render(request,"index.html",html)
The error "index.html" is returned.
Views. py
from django.shortcuts import render# Create your views here.def display_meta(request): values = request.META.items() html = {} html['index_text']=" " html['index_title']='Display META' for k, v in values: html['index_text']+=('<tr><td>%s</td><td>%s</td></tr>' % (k, v)) return render(request,"index.html",html)
Output result
As shown in the figure, the browser cannot explain the output information of the template tag.
Source code download: http://download.csdn.net/detail/a359680405/8388657