Django for Designers: Difference between revisions
Content added Content deleted
imported>Paulproteus (→Handling URLs with templates: Clarify) |
|||
Line 460: | Line 460: | ||
==== Handling URLs with templates ==== |
==== 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: |
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"> |
<source lang="python"> |
||
from django.http import HttpResponse |
|||
from django.shortcuts import render |
from django.shortcuts import render |
||
</source> |
|||
Then, modify the ''index'' function so it looks like this: |
|||
<source lang="python"> |
|||
def index(request): |
def index(request): |
||
context = {} |
context = {} |