Find centralized, trusted content and collaborate around the technologies you use most.
Teams
Q&A for work
Connect and share knowledge within a single location that is structured and easy to search.
我认为标题说明了这一点。许多标签被创建和删除,但即使没有更多对象使用它们,它们仍然存在。
有没有办法让它检查保存和删除未使用的标签?
我能想到的唯一技术是将自定义pre_delete信号处理程序附加到每个可标记模型,以检查它是否是具有任何特定标记的最后一个模型。如果是,请删除该标签。
pre_delete
如果您愿意编辑包代码,则可以使用此处答案中定义的 post_delete 信号处理程序:
删除未被任何其他对象使用的标签