django - 字段 feincms 内容类型上的 FilteredSelectMultiple 小部件

标签 django django-widget feincms

我在 FeinCMS 中有一个定制的内容类型。

class DownloadsContent(models.Model):
    title = models.CharField(max_length=200, verbose_name=_('title'))
    files = FileManyToMany(verbose_name=_('files'))

"file"字段是一个多域字段,仅显示 .doc 和 .pdf 文件:

class FileManyToMany(models.ManyToManyField):
    def __init__(self, to=MediaFile, **kwargs):
        limit = {'type__in': ['doc', 'pdf']}
        limit.update(kwargs.get('limit_choices_to', {}))
        kwargs['limit_choices_to'] = limit
        super(FileManyToMany, self).__init__(to, **kwargs)

到目前为止,一切正常。添加此内容类型时,它会显示所有文件。

但是如何在我的内容类型中使用 FilteredSelectMultiple 小部件?喜欢:

enter image description here

最佳答案

实际上,实现这一目标的更简单方法是:

class DownloadContentInline(FeinCMSInline):
    filter_horizontal = ['files']


class DownloadContent(models.Model):
    feincms_item_editor_inline = DownloadContentInline

关于django - 字段 feincms 内容类型上的 FilteredSelectMultiple 小部件,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/14560955/

相关文章:

python - Heroku 免费层,用于在一个应用程序中实现不间断的 Web 和工作进程

python - Django 1.4 : I get an error in queryset extra

Django 将逗号分隔值传递给 GET 参数

Django - CheckboxSelectMultiple 没有 "------"选择

javascript - 在一页中使用 jQuery datepicker 和多个 django 表单

python - 当用户注销 Django 时如何删除 session ?

django - Django:管理员:更改管理员字段中的小部件

python - Feincms ApplicationContent 覆盖上下文

python - 基于用户自定义feincms页面admin

python - AttributeError at/'str' 对象没有属性 '_mptt_meta'