# django.core.exceptions.ImproperlyConfigured: The SECRET_KEY setting must not be empty.

- **ID:** `python/django-admin-login-redirect-loop`
- **Domain:** python
- **Category:** config_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

The SECRET_KEY is empty or missing in settings, causing authentication and session failures.

## Version Compatibility

| Version | Status | Introduced | Deprecated |
|---------|--------|------------|------------|
| 3.x | active | — | — |

## Workarounds

1. **** (95% success)
   ```
   Generate a new SECRET_KEY using: from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())
   ```
2. **** (90% success)
   ```
   Set SECRET_KEY from environment variable: SECRET_KEY = os.environ.get('DJANGO_SECRET_KEY')
   ```

## Dead Ends

- **** — Insecure and can cause security vulnerabilities; also may not fix the redirect loop if other issues exist. (90% fail)
- **** — Django requires SECRET_KEY; removing it will cause ImproperlyConfigured error. (100% fail)
