Created
February 22, 2010 13:03
-
-
Save vbmendes/311055 to your computer and use it in GitHub Desktop.
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<html> | |
<head> | |
<title>Exemplo</title> | |
</head> | |
<body> | |
{{ model1_objects }} | |
{{ model2_destaque }} | |
</body> | |
</html> |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
from django.conf.urls.defaults import patterns, include, handler404, url | |
urlpatterns = patterns('', | |
url(r'^$', 'specific.views.index', name='index'), | |
) |
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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