Skip to main content

Django Admin

Jarbas ships the standard Django Admin interface at /admin/. It gives you an alternative view of the database that is separate from the public dashboard — useful for inspecting raw records, debugging data quality, and managing users.

Creating a superuser

python manage.py createsuperuser
# Docker
docker-compose run --rm django python manage.py createsuperuser
Follow the prompts to set a username, email, and password. Then navigate to localhost:8000/admin/ and log in.

Available models in the admin

Reimbursement

Every expense claim loaded into Jarbas. Fields include document_id, congressperson_name, supplier, cnpj_cpf, total_net_value, issue_date, suspicions (JSON), and probability. Ordered by year and issue date descending.

ReimbursementSummary

A proxy model over Reimbursement that provides a summary-oriented admin view. Contains the same data but is registered separately for focused browsing.

Tweet

Links between @RosieDaSerenata tweets and specific reimbursements. Each record stores the Twitter status ID and a foreign key to the related Reimbursement.

SocialMedia

Social media profiles for congresspeople, including twitter_profile, secondary_twitter_profile, and facebook_page fields keyed by congressperson_id.

Admin vs public dashboard

CapabilityPublic dashboardDjango Admin
Browse reimbursementsYesYes
Filter by suspicion flagYesYes
Full-text searchYes (requires searchvector)No
Edit or delete recordsNoYes
View raw JSON suspicion dataNoYes
Manage users and permissionsNoYes
Browse tweet linksNoYes
Browse social media profilesNoYes

Healthcheck endpoint

Jarbas exposes a lightweight healthcheck at /healthcheck/. It returns an HTTP 200 response when the application is running correctly. Use it for load balancer health probes or uptime monitoring.
curl http://localhost:8000/healthcheck/

Debug toolbar

When LOG_LEVEL=debug is set in .env, the Django Debug Toolbar is mounted at /__debug__/ and injected into HTML responses. It shows SQL queries, cache hits, template rendering times, and request headers.
The debug toolbar is only active in development (ENVIRONMENT != production). It is never loaded in production builds.
To enable it locally, set the following in your .env:
LOG_LEVEL=debug
ENVIRONMENT=development

Useful maintenance commands

Run after importing new data to make the dashboard search bar reflect the latest records.
python manage.py searchvector
Pass --all to rebuild every record rather than only new ones:
python manage.py searchvector --all
Drops and reloads all reimbursement data from a directory of CSV and LZMA files, then rebuilds suspicions, receipt texts, the search vector, and tweet links.
python manage.py update <directory>
See Data loading — update command for the full step-by-step breakdown.
Runs Django’s system checks to confirm the configuration is valid before starting the server.
python manage.py check
# Docker
docker-compose run --rm django python manage.py check
Runs the full test suite. Tests run without migrations thanks to django-test-without-migrations.
python manage.py test
# Docker
docker-compose run --rm django python manage.py test

Production services

In production, docker-compose.yml runs three Django-based processes:
ContainerCommandRole
djangogunicorn jarbas.wsgi:applicationServes HTTP requests
taskscelery worker --app jarbasProcesses asynchronous tasks
beatcelery beat --app jarbasTriggers scheduled tasks (e.g. searchvector)
All three containers use the same serenata/django image and read configuration from the .env file. New Relic monitoring is enabled by the newrelic-admin run-program wrapper when NEW_RELIC_LICENSE_KEY is set.

Build docs developers (and LLMs) love