# Login History Cleanup - 30 Day Retention

## Overview
Login history records are automatically filtered to show only the last 30 days in the admin panel.
Old records should be deleted automatically using the cleanup command.

## Manual Cleanup
To manually delete login history older than 30 days:
```bash
python manage.py cleanup_login_history
```

## Automatic Cleanup Setup

### Option 1: Windows Task Scheduler
1. Open Task Scheduler
2. Create Basic Task
3. Set trigger: Daily at 2:00 AM
4. Action: Start a program
   - Program: `python`
   - Arguments: `manage.py cleanup_login_history`
   - Start in: `C:\Users\malab\OneDrive\Documents\Projects\nashaajobs-clone`

### Option 2: Linux/Unix Cron Job
Add to crontab (`crontab -e`):
```bash
0 2 * * * cd /path/to/project && python manage.py cleanup_login_history
```

### Option 3: Django-Crontab (Recommended for Production)
1. Install: `pip install django-crontab`
2. Add to INSTALLED_APPS in settings.py:
   ```python
   INSTALLED_APPS = [
       ...
       'django_crontab',
   ]
   ```
3. Add to settings.py:
   ```python
   CRONJOBS = [
       ('0 2 * * *', 'django.core.management.call_command', ['cleanup_login_history']),
   ]
   ```
4. Run: `python manage.py crontab add`

## What's Implemented
✅ View filters to show only last 30 days
✅ Management command to delete old records
✅ Ready for automated scheduling
