Skip to content

Instantly share code, notes, and snippets.

@DJWOMS
Created January 30, 2020 07:13
Show Gist options
  • Save DJWOMS/b88c20da766bca113359c1dc20152249 to your computer and use it in GitHub Desktop.
Save DJWOMS/b88c20da766bca113359c1dc20152249 to your computer and use it in GitHub Desktop.
context_processors для вывода категорий
"""
Данный файл нужно добавить в ваше приложение магазина
"""
from .models import Category
def list_categoryes(request):
"""Список категорий в меню"""
return {"menu_categoryes": Category.objects.all()}
TEMPLATES = [
...
'OPTIONS': {
'context_processors': [
# Добавить ссылку на ваш файл контекст процессора
'shop.context_processors.list_categoryes',
],
...
},
]
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment