Skip to content

Instantly share code, notes, and snippets.

@vbmendes
Created February 22, 2010 13:03
Show Gist options
  • Save vbmendes/311055 to your computer and use it in GitHub Desktop.
Save vbmendes/311055 to your computer and use it in GitHub Desktop.
<html>
<head>
<title>Exemplo</title>
</head>
<body>
{{ model1_objects }}
{{ model2_destaque }}
</body>
</html>
from django.conf.urls.defaults import patterns, include, handler404, url
urlpatterns = patterns('',
url(r'^$', 'specific.views.index', name='index'),
)
from django.views.generic.simple import direct_to_template
from app1.models import Model1
from app2.models import Model2
def index(request):
model1_objects = Model1.objects.all()[:3]
try:
model2_destaque = Model2.objects.all()[:1][0]
except IndexError:
model2_destaque = None
return direct_to_template(request, "index.html", {'model1_objects': model1_objects, 'model2_destaque': model2_destaque})
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment