Django for Designers: Difference between revisions

imported>Paulproteus
Line 460:
==== Handling URLs with templates ====
 
These placeholder responses are okay, but you wouldn't want to make a real webpage in a Python string in the middle of a view function! Fortunately, Django comes with a built-in template renderer! Let's edit views.py. First, at the top, edit the imports to add one fresh import:
 
<source lang="python">
from django.http import HttpResponse
from django.shortcuts import render
</source>
 
Then, modify the ''index'' function so it looks like this:
 
<source lang="python">
def index(request):
context = {}
Anonymous user