wagtail管理员图像和文档标签

wagtail管理员图像和文档标签,wagtail,Wagtail,是否存在如何禁用图像/文档标记的方法?我在我的项目中使用了很多集合,任何用户都可以看到任何集合中的标记这一事实是不需要的,因此我宁愿根本没有标记。我找不到一种方法来阻止他们,因为用户不会看到他们 有什么建议吗?我找到了一种使用信号编辑文档/图像表单的方法。如果有人感兴趣,我的解决方案如下 from django.dispatch import receiver from django.db.models.signals import pre_init from wagtail.documents

是否存在如何禁用图像/文档标记的方法?我在我的项目中使用了很多集合,任何用户都可以看到任何集合中的标记这一事实是不需要的,因此我宁愿根本没有标记。我找不到一种方法来阻止他们,因为用户不会看到他们


有什么建议吗?

我找到了一种使用信号编辑文档/图像表单的方法。如果有人感兴趣,我的解决方案如下

from django.dispatch import receiver
from django.db.models.signals import pre_init
from wagtail.documents.models import Document
from wagtail.images.models import Image

@receiver(pre_init, sender=Document)
def document_form_hide_tags(sender, instance=None, created=False, **kwargs):
    '''
    hides tags from the document form
    '''
    Document.admin_form_fields = (
        'title',
        'file',
        'collection',
        # 'tags'
    )


@receiver(pre_init, sender=Image)
def image_form_hide_tags(sender, instance=None, created=False, **kwargs):
    '''
    hides tags from the image form
    '''
    Image.admin_form_fields = (
        'title',
        'file',
        'collection',
        # 'tags',
        'focal_point_x',
        'focal_point_y',
        'focal_point_width',
        'focal_point_height',
    )