Development Commands
Commands for development, testing, and debugging Django-CFG projects.
Testing Commands
test_email
Send the built-in email templates to one address through the configured backend.
python manage.py test_email --email ADDRESS [--type TYPE]| Option | Type | Default | Description |
|---|---|---|---|
--email | TEXT | required | Recipient address. A user with this email is created if none exists |
--type | TEXT | all | Template to send: all, base, otp, welcome, login_alert |
Examples:
# All templates
python manage.py test_email --email [email protected]
# One template
python manage.py test_email --email [email protected] --type otpThe command has no default recipient: running it without --email is an error.
test_telegram
Test Telegram bot configuration.
python manage.py test_telegram [OPTIONS]| Option | Type | Description |
|---|---|---|
--message | TEXT | Test message to send |
Examples:
# Send test message
python manage.py test_telegram --message "Hello from Django-CFG!"
otp_test
Test OTP authentication system.
python manage.py otp_test [OPTIONS]| Option | Type | Description |
|---|---|---|
--email | TEXT | Email address to test |
Examples:
# Test email OTP
python manage.py otp_test --email [email protected]Script Execution
script
Run custom scripts with full Django context.
python manage.py script [OPTIONS]| Option | Type | Description |
|---|---|---|
--script | TEXT | Name of the script to run |
--list | flag | List available scripts |
--create | TEXT | Create a new script template with this name |
--shell | flag | Open a Django shell |
--check | flag | Run the Django system check |
Without options it opens an interactive menu.
Examples:
# Run a script with Django context
python manage.py script --script my_script
# List available scripts
python manage.py script --list
# Create a script template
python manage.py script --create my_scriptScript Example:
# my_script.py
import sys
from myapp.models import User
def main():
print(f"Total users: {User.objects.count()}")
if len(sys.argv) > 1:
username = sys.argv[1]
user = User.objects.get(username=username)
print(f"Found user: {user.email}")
if __name__ == "__main__":
main()Usage:
python manage.py script --script my_scriptProject Structure
tree
Display Django project structure with documentation.
python manage.py tree [OPTIONS]| Option | Type | Description |
|---|---|---|
--depth, -L | INTEGER | Limit depth |
--all, -a | flag | Include hidden files |
--dirs-only, -d | flag | Directories only |
--no-ignore, -n | flag | Do not skip node_modules, .git and similar |
--include-docker | flag | Include Docker configuration and volumes |
--include-logs | flag | Include log files |
--output, -o | FILE | Write to a file instead of stdout |
--format | tree|json|xml | Output format |
Examples:
# Show project structure
python manage.py tree
# Limit depth
python manage.py tree --depth 3
# Directories only
python manage.py tree --dirs-only
# Write to a file
python manage.py tree --output tree.txtOutput:
📁 myproject/
├── 📄 manage.py
├── 📁 myproject/
│ ├── 📄 __init__.py
│ ├── 📄 config.py
│ ├── 📄 settings.py
│ ├── 📄 urls.py
│ └── 📄 wsgi.py
├── 📁 apps/
│ ├── 📁 blog/
│ ├── 📁 shop/
│ └── 📁 profiles/
└── 📁 static/Code Generation
Generating API clients and FastAPI models has its own commands: gen (Code Generation) and generate_fastapi.
Development Workflows
Complete Development Setup
# 1. Create project
django-cfg create-project my_project
cd my_project/projects/django
# 2. Install dependencies
poetry install
# 3. Setup database
poetry run python manage.py migrate
# 4. Create superuser
poetry run python manage.py createsuperuser
# 5. Start development server
python manage.py runserverWebhook Development Workflow
Exposing your local server to the internet is outside Django-CFG’s scope — run a
tunnel yourself (for example ngrok http 8000 or cloudflared tunnel) and point
your webhook provider at the resulting public URL.
# 1. Start the development server
python manage.py runserver
# 2. Configure the webhook in the external service
# Use: https://<your-public-url>/api/webhooks/stripe/
# 3. Monitor webhook events
# Check Django admin: /admin/payments/webhook/
# 4. Test webhook
curl -X POST https://<your-public-url>/api/webhooks/stripe/ \
-H "Content-Type: application/json" \
-d '{"event": "test"}'Testing Workflow
# 1. Test email configuration
python manage.py test_email --email [email protected]
# 2. Test Telegram bot
python manage.py test_telegram --message "Deploy test"
# 3. Test OTP system
python manage.py otp_test --email [email protected]
# 4. Run unit tests
python manage.py testScript Development Workflow
# 1. Create script
cat > scripts/import_users.py << EOF
from myapp.models import User
import csv
def main():
with open('users.csv') as f:
reader = csv.DictReader(f)
for row in reader:
User.objects.create(
username=row['username'],
email=row['email']
)
print("Import complete!")
if __name__ == "__main__":
main()
EOF
# 2. Run script
python manage.py script scripts/import_users.py
# 3. Check results
python manage.py shell -c "from myapp.models import User; print(User.objects.count())"Tips
- Use
scriptcommand for reusable data operations (not one-off shell commands) - Use
generatecommand for consistent code patterns
Troubleshooting
| Problem | Solution |
|---|---|
| Email test failing | Check: check_settings --email-test, show_config |
| Script errors | Run: script my_script.py --verbosity 2 |