From 33d5d42e92104c7c7741134b22e1471438e2dfde Mon Sep 17 00:00:00 2001 From: Melis Date: Mon, 13 Aug 2018 03:18:00 +0700 Subject: [PATCH 1/2] created templatetag for get variable with django settings.py --- .../templatetags/__init__.py | 0 .../templatetags/custom_tags.py | 9 +++++++++ 2 files changed, 9 insertions(+) create mode 100644 django_admin_listfilter_dropdown/templatetags/__init__.py create mode 100644 django_admin_listfilter_dropdown/templatetags/custom_tags.py diff --git a/django_admin_listfilter_dropdown/templatetags/__init__.py b/django_admin_listfilter_dropdown/templatetags/__init__.py new file mode 100644 index 0000000..e69de29 diff --git a/django_admin_listfilter_dropdown/templatetags/custom_tags.py b/django_admin_listfilter_dropdown/templatetags/custom_tags.py new file mode 100644 index 0000000..6b4f0ed --- /dev/null +++ b/django_admin_listfilter_dropdown/templatetags/custom_tags.py @@ -0,0 +1,9 @@ +from django import template +from django.conf import settings + +register = template.Library() + + +@register.simple_tag +def get_setting(value, default=None): + return getattr(settings, value, default) From ed7c8bff80ba70ac0266f3cdbec718dc9d3af078 Mon Sep 17 00:00:00 2001 From: Melis Date: Mon, 13 Aug 2018 03:22:32 +0700 Subject: [PATCH 2/2] Added the ability to specify the length of the array in settings.py. If the length of the mass is greater than or equal to - the dropdown will be triggered --- .../django_admin_listfilter_dropdown/dropdown_filter.html | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/django_admin_listfilter_dropdown/templates/django_admin_listfilter_dropdown/dropdown_filter.html b/django_admin_listfilter_dropdown/templates/django_admin_listfilter_dropdown/dropdown_filter.html index fc068af..0d3a59c 100644 --- a/django_admin_listfilter_dropdown/templates/django_admin_listfilter_dropdown/dropdown_filter.html +++ b/django_admin_listfilter_dropdown/templates/django_admin_listfilter_dropdown/dropdown_filter.html @@ -1,8 +1,9 @@ -{% load i18n %} +{% load i18n custom_tags %}

{% blocktrans with title as filter_title %} By {{ filter_title }} {% endblocktrans %}