Хабр Курсы для всех
РЕКЛАМА
Практикум, Хекслет, SkyPro, авторские курсы — собрали всех и попросили скидки. Осталось выбрать!
#!/usr/bin/env python
import os, sys
from os.path import abspath, dirname
from werkzeug import run_simple, DebuggedApplication
from django.views import debug
from django.core.handlers.wsgi import WSGIHandler
def null_technical_500_response(request, exc_type, exc_value, tb):
raise exc_type, exc_value, tb
debug.technical_500_response = null_technical_500_response
os.environ['DJANGO_SETTINGS_MODULE'] = 'settings'
path = os.path.abspath(dirname(dirname(abspath(__file__))))
sys.path.append(path)
if __name__ == '__main__':
run_simple('www.site.com', 8000, DebuggedApplication(WSGIHandler(), True), True)
Note that, by default, select_related() does not follow foreign keys that have null=True.
You can refer to any ForeignKey or OneToOneField relation in the list of fields passed to select_related. Ths includes foreign keys that have null=True (unlike the default select_related() call).
@render_to('template.html')
def foo(request):
bar = Bar.object.all()
return {'bar': bar}
def foo(request):
bar = Bar.object.all()
return render_to_response('template.html', {'bar': bar}, context_instance=RequestContext(request))
Наш опыт работы с Django, или 10 полезных модулей, облегчающих жизнь