From 8eedc76d4a94cf6d3066213faa8055d10463fb0d Mon Sep 17 00:00:00 2001 From: j Date: Tue, 23 Nov 2021 17:28:32 +0100 Subject: [PATCH] remove unused items --- app/video/management/commands/load_titles.py | 3 +++ 1 file changed, 3 insertions(+) diff --git a/app/video/management/commands/load_titles.py b/app/video/management/commands/load_titles.py index b79088b..5a12f07 100644 --- a/app/video/management/commands/load_titles.py +++ b/app/video/management/commands/load_titles.py @@ -57,6 +57,7 @@ class Command(BaseCommand): item['summary'] = '' folders[item['folder']]['items'].append(item) + slugs = [] for item in folders.values(): slug = escape_slug(item['title'].split(' / ')[0]) f, c = models.Film.objects.get_or_create(slug=slug) @@ -68,3 +69,5 @@ class Command(BaseCommand): if c: f.public = True f.save() + slugs.append(slug) + models.Film.objects.exclude(slug__in=slugs).delete()