# Settings (/docs/django/settings)

Tracepanel works with no settings. To change one, add the `TRACEPANEL` dict
to your settings:

```python
# settings.py
TRACEPANEL = {
    "slow_sql_ms": 200,
    "ignore_paths": ["/health*", "/static/*"],
}
```

Four Django settings feed Tracepanel's:

- `DEBUG` turns it on.
- `INSTALLED_APPS` must hold `tracepanel.django` for it to turn on.
- `BASE_DIR` is the project's directory. Stack paths are relative to it, and
  the store is in it.
- `INTERNAL_IPS` lists the addresses besides this machine that may switch the
  user. See [Safety](/docs/django/safety#switching-the-user).

## Where settings come from [#where-settings-come-from]

You can set each setting in four places. A later place wins over an earlier
one:

1. `tracepanel.toml`, or `[tool.tracepanel]` in `pyproject.toml`.
2. The `TRACEPANEL` dict in Django's settings.
3. `tracepanel.core.conf.configure()` in code.
4. `TRACEPANEL_<NAME>` environment variables, such as
   `TRACEPANEL_SLOW_SQL_MS=200`. `tracepanel run --set slow_sql_ms=200` sets
   the same variable for one command.

Tracepanel reports an unknown name or a wrong type as an error that names
where the value came from.

`tracepanel config` prints every setting, its value and the place that set
it:

```bash
tracepanel config
```

It doesn't read Django's settings. It shows the values from the defaults,
`tracepanel.toml` or `pyproject.toml`, and the environment variables, but not
the `TRACEPANEL` dict, `DEBUG` or `BASE_DIR`. So `enabled` shows `false` in a
Django project even when Tracepanel is on. Run it from the project's
directory.

## The settings a Django project changes [#the-settings-a-django-project-changes]

| Setting | Default | What it does |
| --- | --- | --- |
| `enabled` | `DEBUG` | Whether Tracepanel records anything. `TRACEPANEL_ENABLED`, which `tracepanel run` sets, wins over `DEBUG`. |
| `slow_sql_ms` | `100` | Queries slower than this are reported as slow SQL. So are MongoDB queries and other datastore calls, as slow calls. |
| `slow_http_ms` | `500` | Outgoing HTTP calls slower than this are reported as slow. |
| `n_plus_one_threshold` | `3` | How many similar queries from one place make an N+1. |
| `n_plus_one_min_ms` | `5` | Repeated Redis commands and cache calls are reported only when they cost this much together. |
| `long_transaction_ms` | `500` | Outer `atomic()` blocks longer than this are reported. |
| `ignore_paths` | `/health*`, `/static/*`, `/media/*`, `/favicon.ico` | Requests whose path matches are not traced. |
| `ignore_commands` | servers, shells, the test runner and workers | Management commands that are not traced. |
| `ignore_tasks` | none | Tasks that are not traced, such as `celery.backend_cleanup`. |
| `ignore_loggers` | none | Loggers whose records are left out, with their children. |
| `user_switch` | `True` | Let the panel show the site as another user. See [Safety](/docs/django/safety). |
| `widget` | `True` | Add the badge and the panel to HTML pages. |
| `prefix` | `/__tracepanel__/` | The URL of the console. |
| `terminal_summary` | `True` | Print a line in the terminal after each task run and management command. |
| `capture_sql_params` | `True` | Keep query parameters and MongoDB values, so the console can run `EXPLAIN`. |
| `capture_locals` | `True` | Keep the local variables of your frames in errors, masked. |
| `capture_mail_body` | `True` | Keep the text and HTML of sent emails. |
| `capture_task_args` | `True` | Keep task arguments and results, masked. |
| `max_traces` | `2000` | How many traces the store keeps. Older ones are deleted. |
| `agent` | `auto` | Where traces go. Set an address when the app runs in a container and the agent outside it. |

Each library integration has an `*_enabled` setting, such as `drf_enabled`.
See [What it records](/docs/django/what-it-records#turn-a-part-off).

Two thresholds are fixed. A task that waited in its queue for a second or more
is a queue wait. A query without a `LIMIT` that returned 1,000 rows or more is
a large result.

The full list, the same for every framework, is in
[Configuration](/docs/python/configuration).
