Guest User

Untitled

a guest
Sep 23rd, 2018
84
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.27 KB | None | 0 0
  1. # This should go in app/templatetags/app_tags.py
  2.  
  3. from django.template import Library
  4.  
  5. from app.models import Post
  6.  
  7. register = Library()
  8.  
  9. @register.inclusion_tag('app/_latest_posts.html')
  10. def latest_posts():
  11. posts = Post.objects.order_by('-date')[:6]
  12. return locals()
Add Comment
Please, Sign In to add comment