This repository has been archived on 2023-05-31. You can view files and clone it, but cannot push or open issues or pull requests.
python-blog/src/attachments/management/commands/reprocess_all_attachments.py

16 lines
500 B
Python

from typing import Any
from django.core.management.base import BaseCommand
from attachments.models import Attachment
class Command(BaseCommand):
help = "Reprocess all attachments" # noqa: A003
def handle(self, *_args: Any, **_options: Any) -> None:
for attachment in Attachment.objects.all():
self.stdout.write(f"Processing {attachment}...")
attachment.reprocess()
self.stdout.write(self.style.SUCCESS("Successfully processed all attachments."))