How can I have django-taggit tags deleted when there are no more objects attached to them?

StackOverflow https://stackoverflow.com/questions/13772750

  •  05-12-2021
  •  | 
  •  

문제

I think the title says it. Many tags are created and deleted but they still exist even when no more objects are using them.

Is there a way to make it check upon save and delete unused tags?

도움이 되었습니까?

해결책

The only technique I can think of would be to attach a custom pre_delete signal handler to every taggable model that checks if it was the last model with any particular tag. In the event that it is, delete that tag.

다른 팁

If you were willing to edit the package code, you could use the post_delete signal handler defined in the answer here:

Deleting the tags that are not used by any other object

라이센스 : CC-BY-SA ~와 함께 속성
제휴하지 않습니다 StackOverflow
scroll top