Django provides session support out-of-the-box and stores sessions in the django_session
database table. Django leaves it up to the project maintainers to purge sessions in their Django project. This means that if it’s not done on a regular basis the table grows infinitely. However, they provide a simple command called clearsessions
for it. Using it within a Celery task in a cron schedule resolves any long-term storage issues with large tables for sessions. The below solution requires both Celery for the task and Celery-beat for the cron schedule.