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

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

## Root Cause

A Jinja2 template references a variable that was not passed to the render context or is None.

## Version Compatibility

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

## Workarounds

1. **** (95% success)
   ```
   return render_template('index.html', user=current_user)
   ```
2. **** (85% success)
   ```
   {% if user is defined %}{{ user.name }}{% endif %}
   ```

## Dead Ends

- **** — The default filter only works if the variable is undefined; if user is None, it still prints 'None'. (60% fail)
- **** — This silences the error but may lead to empty output and hides real bugs. (50% fail)
