Forest is the back office for operations teams in regulated companies. Ops teams review, decide and act on your data from one interface, or let AI agents do it, within the roles, permissions and audit logs you define.
This repository is the Python agent for Django and Flask: the part of Forest that runs inside your application, connects to your databases, and exposes them to the Forest interface. Your business data never goes through Forest.
Note
Forest v2. This is the current Python SDK. Using django-forestadmin? You are on v1: see the migration guide.
pip install forestadmin-agent-djangoThe agent plugs in through your settings, not a constructor:
# settings.py
import os
INSTALLED_APPS = [
# ...
"forestadmin.django_agent",
]
FOREST_AUTH_SECRET = os.environ.get("FOREST_AUTH_SECRET")
FOREST_ENV_SECRET = os.environ.get("FOREST_ENV_SECRET")# urls.py
from django.urls import include, path
urlpatterns = [
path("", include("forestadmin.django_agent.urls")),
]Your Django models are exposed automatically. To add computed fields, actions or segments, point FOREST_CUSTOMIZE_FUNCTION to a function that receives the agent (e.g. "myapp.forest_admin.customize_forest"). The module must exist: if it cannot be imported, the agent does not start.
pip install forestadmin-agent-flask forestadmin-datasource-sqlalchemy flask-sqlalchemyimport os
from flask import Flask
from flask_sqlalchemy import SQLAlchemy
from forestadmin.datasource_sqlalchemy.datasource import SqlAlchemyDatasource
from forestadmin.flask_agent.agent import create_agent
db = SQLAlchemy() # your models are declared on this instance
def create_app():
app = Flask(__name__)
app.config["SQLALCHEMY_DATABASE_URI"] = os.environ["DATABASE_URL"]
# the agent reads its settings from app.config, not from the environment
app.config["FOREST_ENV_SECRET"] = os.environ["FOREST_ENV_SECRET"]
app.config["FOREST_AUTH_SECRET"] = os.environ["FOREST_AUTH_SECRET"]
agent = create_agent(app)
with app.app_context():
db.init_app(app)
agent.add_datasource(SqlAlchemyDatasource(db))
agent.start()
return appFull guide: docs.forest.app/get-started/quickstart
| Python | >=3.8,<3.14 (CI tests 3.8 to 3.13) |
| Django | >=3.2,<5.2 |
| Flask | >=2.0.0 (async extra) |
| SQLAlchemy | >=1.4.0 |
| Data | Your Django models or SQLAlchemy tables, introspected and exposed to Forest. |
| Customization | Computed fields, actions, segments and hooks in Python, from your customize function. |
| Permissions and audit | Roles, scopes and activity logs defined in Forest, enforced on every request. |
The agent runs on your infrastructure. The Forest interface calls your agent, and your agent queries your sources: Forest does not store your business data.
| Get started | https://docs.forest.app/get-started/quickstart |
| Connect a data source | https://docs.forest.app/get-started/connect/data-sources/overview |
| Migrating from v1 | https://docs.forest.app/guides/migration/from-v1/overview |
Packages in this monorepo
| PyPI package | Role |
|---|---|
forestadmin-agent-django |
Agent for Django |
forestadmin-agent-flask |
Agent for Flask |
forestadmin-agent-toolkit |
Agent core (transport, auth, permissions) |
forestadmin-datasource-toolkit |
Data source contracts, queries, types |
forestadmin-datasource-django |
Django ORM data source |
forestadmin-datasource-sqlalchemy |
SQLAlchemy data source |
All packages install into the shared forestadmin.* namespace. Complete demo applications live in src/_example/.
Bug reports and pull requests are welcome. See CONTRIBUTING.md for setup, tests and commit conventions.
./launch_tests_ci_like.sh # runs the CI locallyApache 2.0. See LICENSE.