0

我尝试PageAdmin通过子类化或修补它来修改 feincms。当我使用自定义AdminSite实例时两者都不起作用:MediaLibrary 扩展按钮(它们出现在 之后Page.create_content_type(MediaFileContent...)在我这样做时消失。

from django.contrib import admin
from feincms.module.page.modeladmins import PageAdmin
from feincms.module.page.models import Page

paii_admin = admin.AdminSite(name='paii_admin')
paii_admin.index_template = 'admin/cms/index.html'

class SitePageAdmin(PageAdmin):
    def queryset(self, request):
        return super(SitePageAdmin, self).queryset(request)

paii_admin.register(Page, PageAdmin)
4

1 回答 1

0

我想到了。

您还应该注册 MediaFile(来自 medialibrary):

paii_admin.register(MediaFile, MediaFileAdmin)

feincms/templates/admin/feincms/_content_type_buttons.html我们有以下内容:

{% url "admin:medialibrary_mediafile_changelist" as media_library_url %}
[...]
{% if media_library_url %}
    }, {
        type: 'mediafilecontent',
        keep: true,
        cssclass: 'imagecontent',
        raw_id_picker: '{{ media_library_url }}?type__exact=image&pop=1'
    }, {
        type: 'gallerycontent',
        keep: true
    }, {
        type: 'mediafilecontent',
        keep: true,
        cssclass: 'pdfcontent',
        raw_id_picker: '{{ media_library_url }}?type__exact=pdf&pop=1'
{% endif %}

仅当 medialibrary 注册到命名空间时,这些字段才由 JS 填充

于 2013-07-01T16:04:53.960 回答