Built-in Management Commands
All commands run via buraq <command>.
Global options
Section titled “Global options”Global options
Section titled “Global options”These options are accepted by every command:
| Option | Env var | Description |
|---|---|---|
--settings MODULE |
BURAQ_SETTINGS_MODULE |
Dotted path to the settings module to use |
# Use production settings for a single commandburaq migrate --settings config.prod_settings
# Or set the env var once for the whole shell sessionexport BURAQ_SETTINGS_MODULE=config.prod_settingsburaq migrateburaq createsuperuserWhen --settings is given, Buraq imports the named module and applies every upper-case attribute to the live settings object before the command runs. This lets you keep separate settings files for development, staging, and production without changing manage.py.
Running the project
Section titled “Running the project”Server
Section titled “Server”# Start development server (default: main:app on 127.0.0.1:8000)buraq runserver
# Custom port (Django-style)buraq runserver 8080
# Custom host:portburaq runserver 0.0.0.0:8080
# Custom app pathburaq runserver main:app
# Optionsburaq runserver --no-reload # disable auto-reloadburaq runserver --workers 4 # multiple workers (disables reload)Test server
Section titled “Test server”# Load fixtures then start the development serverburaq testserver fixtures/posts.json fixtures/users.jsonburaq testserver fixtures/initial.json --port 8001buraq testserver fixtures/initial.json --no-input # skip confirmationburaq testserver fixtures/initial.json --app main:app # custom app pathClears the database, loads the given fixture files, then starts the dev server. Useful for manual QA sessions with realistic data without touching the production database.
Background task worker
Section titled “Background task worker”buraq workerburaq worker --queue high-priority --concurrency 4buraq worker --queue email --poll-interval 0.5 --max-tasks 100Polls the task backend for pending tasks and executes them. Requires DatabaseBackend — the DummyBackend executes tasks in-process and needs no worker.
| Flag | Default | Description |
|---|---|---|
--queue, -q |
default |
Queue name to consume |
--concurrency, -c |
1 |
Concurrent task coroutines |
--poll-interval |
1.0 |
Seconds between database polls |
--max-tasks |
0 (∞) |
Stop after processing N tasks |
The worker exits cleanly on SIGINT / SIGTERM. See Background Tasks.
Database
Section titled “Database”Database
Section titled “Database”# Generate migration from model changesburaq makemigrationsburaq makemigrations "add slug to post"
# Apply all pending migrationsburaq migrate
# Migrate to a specific revisionburaq migrate abc1234
# Roll back migrationsburaq rollback # 1 migrationburaq rollback 3 # 3 migrations
# View migration historyburaq showmigrationsMigrations (advanced)
Section titled “Migrations (advanced)”# Print the SQL a migration would run without executing itburaq sqlmigrate abc1234buraq sqlmigrate abc1234 --backwards # downgrade SQL
# Squash a range of migrations into oneburaq squashmigrations abc1234 headburaq squashmigrations abc1234 head --name squashed_v2
# Merge two divergent migration heads into oneburaq optimizemigration abc1234 def5678buraq optimizemigration abc1234 def5678 --name merge_branches
# Print the SQL that flush would run (without executing it)buraq sqlflush
# Print SQL to reset PostgreSQL autoincrement sequencesburaq sqlsequenceresetburaq sqlsequencereset posts auth # specific apps onlysqlflush is useful for auditing or generating a manual reset script. sqlsequencereset is only needed for PostgreSQL after bulk data imports that bypass the ORM.
Database shell
Section titled “Database shell”# Open the native CLI for the configured databaseburaq dbshellDetects the dialect from DATABASE_URL and launches sqlite3, psql, or mysql with the correct connection arguments. Requires the database CLI to be installed on PATH.
Inspect database
Section titled “Inspect database”# Print model class stubs inferred from the live schemaburaq inspectdb
# Inspect a specific tableburaq inspectdb --table posts_post
# Redirect to a fileburaq inspectdb > myapp/models.pyUses SQLAlchemy’s inspect() to read table names, column types, and constraints, then maps them to Buraq field strings.
# Delete all rows from every table (schema is kept)buraq flush
# Skip the confirmation promptburaq flush --no-inputTables are truncated in reverse dependency order to avoid FK violations. Prompts for confirmation unless --no-input is passed.
Data import / export
Section titled “Data import / export”# Dump all tables to JSONburaq dumpdataburaq dumpdata --output fixtures/initial.jsonburaq dumpdata --indent 2buraq dumpdata --exclude auth_user --exclude buraq_sessions
# Load a JSON fixtureburaq loaddata fixtures/initial.jsonburaq loaddata fixtures/initial.json --table posts_postdumpdata serialises every SQLAlchemy table to a JSON list. loaddata bulk-inserts rows; use --table to restrict which tables are loaded.
Projects, apps and assets
Section titled “Projects, apps and assets”Apps & Projects
Section titled “Apps & Projects”# Scaffold a new appburaq startapp posts
# Scaffold a new projectburaq startproject myproject
# Put it somewhere other than ./myprojectburaq startproject myproject blog_folder
# --dest does the same thing, for scripts written against earlier versionsburaq startproject myproject --dest blog_folder
buraq startproject myproject --postgres # with PostgreSQL configThe files land directly in the directory you name — no second folder is
nested inside it. Without one, the project goes in ./<name>.
Static files
Section titled “Static files”# Collect all static files into STATIC_ROOTburaq collectstatic
# Custom destination (overrides STATIC_ROOT)buraq collectstatic --dest /var/www/static
# Wipe destination before collectingburaq collectstatic --clear
# Find where a static file lives (searches STATICFILES_FINDERS)buraq findstatic css/style.cssburaq findstatic images/logo.png --first # stop at first matchFiles are discovered via STATICFILES_FINDERS (searches STATICFILES_DIRS and each installed app’s static/ directory) and saved via STATICFILES_STORAGE. When ManifestStaticFilesStorage is active, content-hashed copies are written and staticfiles.json is generated.
Output:
Collecting static files into /app/staticfiles ...Done. Copied: 24, Skipped (unchanged): 8, Post-processed: 24findstatic prints the absolute path for each match across all finders:
/app/static/css/style.css/app/myapp/static/css/style.cssPackage management
Section titled “Package management”Buraq has no package commands of its own. Use whatever the project already uses:
uv add requests httpx # uvpoetry add requests httpx # Poetrypip install requests httpx # pipThere were wrappers here — buraq install, uninstall, sync, pip and
run — and they forwarded one option each out of the sixty-odd their tools
accept, under names that did not match. Anything past the simplest case had to
be run against the real command anyway, so they are gone.
# Create a superuser (interactive — prompts for username, email, password)buraq createsuperuser
# Pass values directly (password is still prompted if omitted)buraq createsuperuser --username admin --email admin@example.com
# Fully non-interactive (for scripts / CI)buraq createsuperuser --username admin --email admin@example.com --password secret --no-inputThe interactive flow asks for username, email, and password (with a confirmation prompt). It rejects empty passwords and mismatched confirmation attempts. Exits with an error if the username or email is already taken.
Change password
Section titled “Change password”buraq changepassword alicePrompts for a new password (with confirmation) and updates hashed_password for the named user via hash_password().
Inspecting a project
Section titled “Inspecting a project”System checks
Section titled “System checks”# Run all registered system checksburaq checkPrints results grouped by severity (INFO, WARNING, ERROR, CRITICAL). Exits with code 1 if any ERROR-level check fails.
The checks themselves, and how to add your own, are in System checks.
Diff settings
Section titled “Diff settings”# Show settings that differ from defaultsburaq diffsettings
# Show every setting (including defaults)buraq diffsettings --allChanged settings are marked with ### so they’re easy to spot.
URL inspection
Section titled “URL inspection”# List all registered routes (default app: main:app)buraq listurls
# Use a specific appburaq listurls --app main:appOutput:
Path View Name------------------------------------------------------------------------/ myapp.views.home home/posts myapp.views.post_list post_list/posts/{pk} myapp.views.post_detail post_detail/auth/login buraq.contrib.auth.views.LoginView loginNamed routes appear in the Name column. Unnamed routes show an empty name.
Interactive shell
Section titled “Interactive shell”# Open an interactive Python shell with models pre-importedburaq shell
# Run a single expression and exitburaq shell -c "print(await Post.objects.count())"All model classes from INSTALLED_APPS and SessionLocal are auto-imported so you can query the database immediately.
Content types
Section titled “Content types”# Remove ContentType records for models that no longer existburaq remove_stale_contenttypesburaq remove_stale_contenttypes --no-input # skip confirmationburaq remove_stale_contenttypes --include-stale-apps # also check still-installed appsRun this after removing an app or model from INSTALLED_APPS to clean up orphaned rows in the contenttypes table. See Content Types.
Version
Section titled “Version”buraq version# Buraq 0.1.0Caching, sessions and translations
Section titled “Caching, sessions and translations”# Clear all cached databuraq clearcache
# Create the database cache table (DatabaseCache backend)buraq createcachetableburaq createcachetable --table my_cache_tableSessions
Section titled “Sessions”# Delete all expired sessions from the database session tableburaq clearsessionsOnly relevant when using DatabaseSessionBackend. Cookie-based sessions need no cleanup.
Internationalization
Section titled “Internationalization”# Extract translatable strings into .po filesburaq makemessages -l arburaq makemessages -l ar -l fr -l es # multiple locales at onceburaq makemessages -l ar --domain django # custom domain
# Compile .po files into binary .mo filesburaq compilemessages
# Custom domainburaq compilemessages --domain djangoRequires babel (pip install babel). Strings are extracted from .py and .html files by default. Compiled .mo files are written next to the .po files in locale/<lang>/LC_MESSAGES/.
See Internationalization for full usage.
Testing and email
Section titled “Testing and email”Test runner
Section titled “Test runner”# Run the test suite via pytestburaq testburaq test tests/buraq test --failfastburaq test --verbosity 2BURAQ_ENV=test is set automatically so settings can branch on it.
Send test email
Section titled “Send test email”# Verify email configurationburaq sendtestemail alice@example.comSends a plain-text test message using the configured email backend (EMAIL_HOST, EMAIL_PORT, credentials). Use this to confirm SMTP settings before deploying.
Writing your own
Section titled “Writing your own”CommandError / SystemCheckError
Section titled “CommandError / SystemCheckError”Custom management commands raise CommandError to print an error message and exit with a non-zero code without a Python traceback:
from buraq.management.base import CommandError
class Command(BaseCommand): async def handle(self, *args, **options): if not options["name"]: raise CommandError("--name is required.")SystemCheckError is a subclass raised automatically by the check command when one or more registered system checks report an ERROR-level issue. You do not normally raise it directly.
execute_from_command_line
Section titled “execute_from_command_line”execute_from_command_line is the entry point used by manage.py:
#!/usr/bin/env python"""Run: python manage.py <command>"""import os, sysfrom pathlib import Path
if Path(".venv/bin/python").exists(): os.execv(".venv/bin/python", [".venv/bin/python"] + sys.argv)
from buraq.management.cli import execute_from_command_lineexecute_from_command_line(sys.argv)This is generated automatically when you run buraq startproject.