# Django

{% hint style="success" %}
This is the official documentation of the `forestadmin-agent-django` and `forestadmin-agent-flask` Python agents.
{% endhint %}

### Add dependency forestadmin-agent-django to your Django app

```bash
pip install forestadmin-agent-django
```

You need to setup the forest Forest Admin agent, and CORS header settings.

{% tabs %}
{% tab title="project/settings.py" %}

```python
# define the forest admin settings
FOREST_AUTH_SECRET = os.environ.get("FOREST_AUTH_SECRET")
FOREST_ENV_SECRET = os.environ.get("FOREST_ENV_SECRET")

# add it in the installed apps
INSTALLED_APPS = [
    # ...
    "forestadmin.django_agent",
    "corsheaders",
    # ...
]

# CORS settings
# see https://github.com/adamchainz/django-cors-headers for more details
MIDDLEWARE = [
    # ...
    # just before CommonMiddleware
    "corsheaders.middleware.CorsMiddleware",
    "django.middleware.common.CommonMiddleware",
    # ...
]
CORS_ALLOWED_ORIGIN_REGEXES = [
    r".*\.forestadmin\.com.*",
]
CORS_ALLOW_CREDENTIALS = True
```

{% endtab %}

{% tab title="project/urls.py" %}

```python
from django.urls import include, path

urlpatterns = [
    # ...
    path("", include("forestadmin.django_agent.urls")),
    # ...
]

```

{% endtab %}
{% endtabs %}

Running

```bash
FOREST_ENV_SECRET="<This is provided during the onboarding steps>" FOREST_AUTH_SECRET="<This is provided during the onboarding steps>" python manage.py runserver
```

should be enough to be redirected to the "rate-install" page.


---

# Agent Instructions: Querying This Documentation

If you need additional information that is not directly available in this page, you can query the documentation dynamically by asking a question.

Perform an HTTP GET request on the current page URL with the `ask` query parameter:

```
GET https://docs.forestadmin.com/developer-guide-agents-python/getting-started/quick-start/quick-start-django.md?ask=<question>
```

The question should be specific, self-contained, and written in natural language.
The response will contain a direct answer to the question and relevant excerpts and sources from the documentation.

Use this mechanism when the answer is not explicitly present in the current page, you need clarification or additional context, or you want to retrieve related documentation sections.
