python django.contrib.admin的下拉过滤器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了python django.contrib.admin的下拉过滤器相关的知识,希望对你有一定的参考价值。

<script type="text/javascript">
  var go_from_select = function(opt) {
    window.location = window.location.pathname + opt
  };
</script>

<h3>By {{ title }}</h3>
<ul class="admin-filter-{{ title|cut:' ' }}">
  <select style="width: 95%;"
      onchange="go_from_select(this.options[this.selectedIndex].value)">
      {% for choice in choices %}
        <option{% if choice.selected %} selected="selected"{% endif %}
         value="{{ choice.query_string|iriencode }}">{{ choice.display }}</option>
      {% endfor %}
  </select>
</ul>
from django.contrib.admin.filters import RelatedFieldListFilter
from django.contrib import admin


class RelatedDropdownFilter(RelatedFieldListFilter):
    template = 'admin/dropdown_filter.html'
    
    
@admin.register(Member)
class MemberAdmin(admin.ModelAdmin):
    list_display = ['full_name', 'university', 'phone']
    list_filter = [('university', RelatedDropdownFilter)]

以上是关于python django.contrib.admin的下拉过滤器的主要内容,如果未能解决你的问题,请参考以下文章

Python代写,Python作业代写,代写Python,代做Python

Python开发

Python,python,python

Python 介绍

Python学习之认识python

python初识