Chargement des catégories par templatetag.
This commit is contained in:
parent
afb8d3c0ec
commit
1b830b87fb
2 changed files with 15 additions and 0 deletions
0
content/templatetags/__init__.py
Normal file
0
content/templatetags/__init__.py
Normal file
15
content/templatetags/categories.py
Normal file
15
content/templatetags/categories.py
Normal file
|
@ -0,0 +1,15 @@
|
|||
from django import template
|
||||
from content.models import Category
|
||||
|
||||
register = template.Library()
|
||||
|
||||
|
||||
@register.tag('load_categories')
|
||||
def load_site_settings(parser, token):
|
||||
return LoadCategoriesNode()
|
||||
|
||||
|
||||
class LoadCategoriesNode(template.Node):
|
||||
def render(self, context):
|
||||
context['categories'] = Category.objects.all()
|
||||
return ''
|
Loading…
Reference in a new issue