Created
June 18, 2012 00:44
-
-
Save douglasmiranda/2946192 to your computer and use it in GitHub Desktop.
resposta para discussão na django brasil https://groups.google.com/forum/?fromgroups#!topic/django-brasil/jdKQF_U4I0g
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 import View | |
from django.template.response import TemplateResponse | |
from news.models import Noticia | |
from videos.models import Video | |
from datetime import datetime | |
class HomeView(View): | |
template_name = 'home/home.html' | |
def get(self, request, *args, **kwargs): | |
context = self.get_context_data(**kwargs) | |
return TemplateResponse( | |
request=self.request, | |
template=self.template_name, | |
context=context, | |
**kwargs | |
) | |
def get_context_data(self, **kwargs): | |
context = {} | |
context['noticias_em_destaque'] = Noticia.objects.destaques()[:7] | |
context['videos'] = Video.objects.filter(publicacao__lte=datetime.now())[:4] | |
return context |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment