doc:appunti:prog:django
Differences
This shows you the differences between two versions of the page.
Both sides previous revisionPrevious revisionNext revision | Previous revisionLast revisionBoth sides next revision | ||
doc:appunti:prog:django [2011/06/26 11:13] – [Mettere i dati nella vista] niccolo | doc:appunti:prog:django [2011/06/26 11:49] – [Mettere i dati nella vista] niccolo | ||
---|---|---|---|
Line 165: | Line 165: | ||
</ | </ | ||
''' | ''' | ||
- | u'Balance' | + | u'Titolo della vista' |
) | ) | ||
return HttpResponse(output) | return HttpResponse(output) | ||
Line 187: | Line 187: | ||
Invece di includere il codice HTML direttamente nella vista (funzione Python) si utilizza il sistema dei **template**. | Invece di includere il codice HTML direttamente nella vista (funzione Python) si utilizza il sistema dei **template**. | ||
- | Nella directory radice del progetto si crea la sottodirectory **'' | + | Nella directory radice del progetto si crea la sottodirectory **'' |
<code python> | <code python> | ||
+ | import os.path | ||
+ | |||
TEMPLATE_DIRS = ( | TEMPLATE_DIRS = ( | ||
os.path.join(os.path.dirname(__file__), | os.path.join(os.path.dirname(__file__), | ||
Line 213: | Line 215: | ||
from django.template.loader import get_template | from django.template.loader import get_template | ||
- | def balance(request): | + | def my_view(request): |
- | template = get_template(' | + | template = get_template(' |
variables = Context({ | variables = Context({ | ||
' | ' | ||
Line 222: | Line 224: | ||
return HttpResponse(output) | return HttpResponse(output) | ||
</ | </ | ||
+ | |||
+ | FIXME Da fare: | ||
+ | |||
+ | * Aggiungere nella vista l' | ||
+ | * Aggiungere nel template l' | ||
+ | * Trovare il modo per mostrare i dati aggregati (somma di un campo, ecc.). | ||
===== Webserver di test ===== | ===== Webserver di test ===== | ||
doc/appunti/prog/django.txt · Last modified: 2011/06/28 09:15 by niccolo