# jinja2.exceptions.UndefinedError: 'user' is undefined

- **ID:** `python/flask-jinja2-undefinederror-variable-undefined`
- **Domain:** python
- **Category:** runtime_error
- **Verification:** ai_generated
- **Fix Rate:** 80%

## Root Cause

Template references a variable that was not passed to the template context.

## Version Compatibility

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

## Workarounds

1. **Pass variable in render_template** (95% success)
   ```
   return render_template('index.html', user=current_user)
   ```
2. **Use default filter in template** (90% success)
   ```
   {{ user | default('Guest') }}
   ```

## Dead Ends

- **Adding variable in wrong route** — Variable must be passed in the specific route that renders the template. (50% fail)
- **Using global variable without context** — Flask templates don't inherit global variables without explicit passing. (70% fail)
