django cleanup

  1. Import the necessary module:
from django_cron import Job
  1. Create a new class that inherits from the Job class:
class YourCleanupJob(Job):
    ...
  1. Implement the run method within this class. This is where you define the cleanup logic:
def run(self):
    # Your cleanup logic goes here
    ...
  1. Add any necessary parameters to the run method for customization:
def run(self, args, *kwargs):
    # Your cleanup logic using any provided parameters
    ...
  1. Register the job with Django's cron scheduler by adding it to the CRON_CLASSES setting in settings.py:
CRON_CLASSES = [
    "your_app_name.path.to.YourCleanupJob",
    ...
]