标签:django
共 2 篇
-
Django Admin 使用 filter_horizontal 不生效
Django 1.2.7 admin在使用ManyToManyField的时候,默认使用垂直filter_vertical方式进行显示与选择。此方式在选项比较多的时候,难以直观的看出哪些选项被选中,在尝试使用filter_horizontal进行显示的时候,我们碰到了一些问题。
-
Django multiple select option with title
from django import forms from django.utils.encoding import force_unicode from django.utils.html import escape, conditional_escape class SelectMultipleWithTitle(forms.SelectMultiple): """ multiple select optihon with title """ def render_option(self, selected_choices, option_value, option_label): option_value = force_unicode(option_value) selected_html = (option_value in selected_choices) and u' selected="selected"' or '' return u'