Django管理员的filter_horizo​​ntal(& filter_vertical)无法正常工作 [英] Django admin's filter_horizontal (& filter_vertical) not working

查看:164
本文介绍了Django管理员的filter_horizo​​ntal(& filter_vertical)无法正常工作的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我正在尝试对ManyToMany字段使用ModelAdmin.filter_horizo​​ntal和ModelAdmin.filter_vertical而不是选择多个框,但是我得到的是:

I'm trying to use ModelAdmin.filter_horizontal and ModelAdmin.filter_vertical for ManyToMany field instead of select multiple box but all I get is:

我的模型:


class Title(models.Model):
    #...
    production_companies = models.ManyToManyField(Company, verbose_name="компании-производители")
    #...

我的管理员:


class TitleAdmin(admin.ModelAdmin):
    prepopulated_fields = {"slug": ("original_name",)}
    filter_horizontal = ("production_companies",)
    radio_fields = {"state": admin.HORIZONTAL}
    #...

JavaScript正在加载正常,我真的不知道会发生什么。 Django 1.1.1稳定。

The javascripts are loading OK, I really don't get what happens. Django 1.1.1 stable.

推荐答案

我终于得到了解决方案。问题出在该字段的冗长名称-它是str而不是unicode。转向unicode有所帮助。

I finally got the solution. The problem was with the field's verbose name - it was str instead of unicode. Moving to unicode helped.

谢谢:-)

这篇关于Django管理员的filter_horizo​​ntal(& filter_vertical)无法正常工作的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
相关文章
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆