django-axes/axes/management/commands/axes_reset_logs.py
2019-09-28 19:28:17 +03:00

22 lines
643 B
Python

from django.core.management.base import BaseCommand
from axes.handlers.proxy import AxesProxyHandler
class Command(BaseCommand):
help = "Reset access log records older than given days."
def add_arguments(self, parser):
parser.add_argument(
"--age",
type=int,
default=30,
help="Maximum age for records to keep in days",
)
def handle(self, *args, **options):
count = AxesProxyHandler.reset_logs(age_days=options["age"])
if count:
self.stdout.write(f"{count} logs removed.")
else:
self.stdout.write("No logs found.")