Skip to content

Added the ability to specify the length in the settings.py array itself at which the dropdown will work #14

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 2 commits into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
Original file line number Diff line number Diff line change
@@ -1,8 +1,9 @@
{% load i18n %}
{% load i18n custom_tags %}
<script type="text/javascript">var go_from_select = function(opt) { window.location = window.location.pathname + opt };</script>
<h3>{% blocktrans with title as filter_title %} By {{ filter_title }} {% endblocktrans %}</h3>
<ul class="admin-filter-{{ title|cut:' ' }}">
{% if choices|slice:"4:" %}
{% get_setting "DROPDOWN_THRESHOLD" 4 as dropdown_threshold %}
{% if dropdown_threshold <= choices|length %}
<li>
<select class="form-control" style="width: 95%;margin-left: 2%;"
onchange="go_from_select(this.options[this.selectedIndex].value)">
Expand All @@ -20,4 +21,4 @@ <h3>{% blocktrans with title as filter_title %} By {{ filter_title }} {% endbloc
{% endfor %}

{% endif %}
</ul>
</ul>
Empty file.
9 changes: 9 additions & 0 deletions django_admin_listfilter_dropdown/templatetags/custom_tags.py
Original file line number Diff line number Diff line change
@@ -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)