wagtail - 鹡鸰管理图像和文档标签
问题描述
无论如何如何禁用图像/文档标签?我在我的项目中使用了很多集合,并且任何用户都可以看到来自任何集合的标签这一事实是不受欢迎的,因此我宁愿根本没有标签。我找不到如何将它们禁用给用户看不到它们的方法。
有什么建议吗?
解决方案
我找到了一种使用信号编辑文档/图像表单的方法。如果有人感兴趣,我的解决方案如下
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',
)
推荐阅读
- javascript - 在 Puppeteer 中获取所有带有 XPath 的链接(暂停或不工作)?
- c - 用函数排序数组而不使用 C 中的指针没有成功。为什么?
- reactjs - 从另一个组件获取值到 redux 表单字段中
- c# - 将 Unity 的 RGBA 数组转换为 YUV 字节数组
- python-3.x - 使用变量键访问字典中的值
- c++ - 编辑树视图项目不会自动更新数据库
- list - 在转到 Delve 的列表视图中禁用单击事件
- c# - c#依赖没有实例化
- json - 在 Laravel 中处理 JSON 响应的最佳方法
- oracle-sqldeveloper - SQL Developer 工具日志窗口