Skip to content
Snippets Groups Projects
Commit 287263a9 authored by HeJ's avatar HeJ
Browse files

add 'housekeeping' management command

parent 8fbc6719
No related branches found
No related tags found
No related merge requests found
from django.core.management.base import BaseCommand
from django.utils import timezone
from ...models.messages import DirectMessage
class Command(BaseCommand):
def handle(self, *args, **options):
# clear all direct messages which are after their expiry date
deleted_msgs_count, _ = DirectMessage.objects.filter(autodelete_after__isnull=False, autodelete_after__lte=timezone.now()).delete()
print(f'Deleted {deleted_msgs_count} messages.')
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment