# HG changeset patch # User neko259 # Date 2016-01-29 11:43:51 # Node ID c40a0537bde289995f628594d843243bb4991723 # Parent a16adec62ba0dad611f7f9c154416a57226c6337 When editing tags in admin, add their parents as in a thread creation form diff --git a/boards/admin.py b/boards/admin.py --- a/boards/admin.py +++ b/boards/admin.py @@ -56,6 +56,15 @@ class ThreadAdmin(admin.ModelAdmin): def op(self, obj: Thread): return obj.get_opening_post_id() + # Save parent tags when editing tags + def save_related(self, request, form, formsets, change): + super().save_related(request, form, formsets, change) + obj = form.instance + for tag in obj.get_tags().all(): + parents = tag.get_all_parents() + if len(parents) > 0: + obj.tags.add(*parents) + list_display = ('id', 'op', 'title', 'reply_count', 'status', 'ip', 'display_tags') list_filter = ('bump_time', 'status')