Advertisement
Guest User

Untitled

a guest
Apr 11th, 2019
81
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
Python 0.71 KB | None | 0 0
  1. custom_templates.py
  2. from django import template
  3. register = template.Library()
  4.  
  5. @register.filter
  6. def index(d, key):
  7.     return d[key]
  8.  
  9. settings.py
  10. TEMPLATES = [
  11.     {
  12.         'BACKEND': 'django.template.backends.django.DjangoTemplates',
  13.         'DIRS': [TEMPLATE_DIR],
  14.         'APP_DIRS': True,
  15.         'OPTIONS': {
  16.             'context_processors': [
  17.                 'django.template.context_processors.debug',
  18.                 'django.template.context_processors.request',
  19.                 'django.contrib.auth.context_processors.auth',
  20.                 'django.contrib.messages.context_processors.messages',
  21.             ],
  22.             'libraries': 'app.templatetags.custom_templates',
  23.         },
  24.     },
  25. ]
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement