Django development tools for database exploration and code execution
Project description
๐ง Django DevTools
A complete Django development tools package, allowing you to explore the database, run Python/SQL code, and test functions in development mode.
โจ Features
- ๐๏ธ Model Exploration: Automatic visualization of all Django models
- ๐ Data View: Paginated browsing of table contents with search
- ๐ Python Console: Live Python code execution with access to the Django ORM
- ๐๏ธ SQL Console: Raw SQL query execution
- ๐ Database Schema: Visualization of the complete database structure
- โ๏ธ Function Testing: Interface for testing your apps' utility functions
- ๐ Enhanced Security: Restricted access to DEBUG mode and superusers
- ๐ฑ Responsive Interface: Modern design with Bootstrap 5
๐ Requirements
- Python: 3.8+ (3.10+ recommended for Django 5.x)
- Django: 3.2+ | 4.x | 5.x
- Database: MySQL, PostgreSQL, SQLite, Oracle supported
- Browser: Modern browsers (Chrome, Firefox, Safari, Edge)
๐ Installation
Installation via pip (recommended)
pip install django-devtools-local
Installation from sources
git clone https://github.com/yourusername/django-devtools.git
cd django-devtools
pip install -e .
โ๏ธ Configuration
1. Adding to INSTALLED_APPS
# settings.py
INSTALLED_APPS = [
# ... your other apps
'devtools',
]
2. Configuring URLs
# urls.py (main project)
from django.contrib import admin
from django.urls import path, include
from django.conf import settings
urlpatterns = [
path('admin/', admin.site.urls),
# ... your other URLs
]
# Adding DevTools only in DEBUG mode
if settings.DEBUG:
urlpatterns += [
path('devtools/', include('devtools.urls')),
]
3. Optional Configuration
# settings.py
# Allowed IP addresses for DevTools (default: localhost only)
DEVTOOLS_ALLOWED_IPS = [
'127.0.0.1',
'::1',
# Add more IP addresses if needed
]
# Optional middleware for enhanced security
MIDDLEWARE = [
# ... your other middleware
'devtools.middleware.DevToolsSecurityMiddleware', # Optional
]
๐ฏ Usage
Accessing DevTools
- Ensure
DEBUG = Truein your settings - Log in with a superuser account
- Go to
http://localhost:8000/devtools/
Navigation
- Home: Overview of models and statistics
- Tables: Exploring data with Pagination and Search
- Console: Live Python/SQL Code Execution
- Schema: Database Structure Visualization
- Functions: Test Your Application's Utility Functions
Usage Examples
Python Console
# List all users
from django.contrib.auth.models import User
users = User.objects.all()
for user in users:
print(f"{user.username} - {user.email}")
# Model Statistics
for app in apps.get_app_configs():
for model in app.get_models():
count = model.objects.count()
print(f"{model.__name__}: {count} objects")
SQL Console
-- Analysis Queries
SELECT table_name, table_rows
FROM information_schema.tables
WHERE table_schema = DATABASE()
ORDER BY table_rows DESC;
-- User statistics
SELECT COUNT(*) as total_users,
COUNT(CASE WHEN is_active = 1 THEN 1 END) as active_users
FROM auth_user;
๐ Security
Access Restrictions
DevTools applies several levels of security:
- DEBUG Mode Required: Works only with
DEBUG = True - Authentication: Only logged-in users can access
- Superuser Privileges: Only superusers have access
- IP Whitelisting: Restricted by IP address (localhost by default)
Enhanced Security Configuration
# settings.py
# For maximum security
DEVTOOLS_ALLOWED_IPS = ['127.0.0.1'] # Localhost only
# Adding security middleware
MIDDLEWARE = [
# ... other middleware
'devtools.middleware.DevToolsSecurityMiddleware',
]
๐จ Customization
Custom CSS
Create a custom CSS file:
/* static/css/devtools-custom.css */
:root {
--devtools-primary: #your-color;
}
.devtools-custom {
/* Your custom styles */
}
Custom Templates
You can override templates by creating:
your_app/templates/devtools/
โโโ base.html
โโโ index.html
โโโ tables.html
โโโ query.html
๐ท Screenshots
Dashboard Overview
Python Console
Database Schema
๐ ๏ธ Development
Project Structure
django-devtools/
โโโ devtools/
โ โโโ __init__.py
โ โโโ admin.py
โ โโโ apps.py
โ โโโ views.py
โ โโโ urls.py
โ โโโ utils.py
โ โโโ middleware.py
โ โโโ templates/devtools/
โ โ โโโ base.html
โ โ โโโ index.html
โ โ โโโ tables.html
โ โ โโโ query.html
โ โ โโโ schema.html
โ โ โโโ functions.html
โ โโโ static/devtools/
โ โ โโโ css/style.css
โ โ โโโ js/app.js
โ โโโ templatetags/
โ โโโ devtools_extras.py
โโโ setup.py
โโโ LICENSE
โโโ README.md
Local Development Setup
# Clone the project
git clone https://github.com/yourusername/django-devtools.git
cd django-devtools
# Create virtual environment
python -m venv venv
source venv/bin/activate # On Windows: venv\Scripts\activate
# Install dependencies
pip install -e .
# Run tests
python -m pytest tests/
# Create example Django project for testing
django-admin startproject testproject
cd testproject
# Add 'devtools' to INSTALLED_APPS
# Configure URLs
python manage.py migrate
python manage.py createsuperuser
python manage.py runserver
Running Tests
# Run all tests
python -m pytest
# Run with coverage
pip install pytest-cov
python -m pytest --cov=devtools
# Run specific test file
python -m pytest tests/test_views.py
๐ Troubleshooting
Common Issues
DevTools not accessible
- โ
Ensure
DEBUG = Truein settings - โ Check that you're logged in as a superuser
- โ Verify URLs are properly configured
- โ Check IP whitelist settings
Permission denied errors
- โ Verify user has superuser privileges
- โ Check IP address is in DEVTOOLS_ALLOWED_IPS
- โ Ensure proper middleware configuration
Database connection errors
- โ Verify database configuration
- โ Check database permissions
- โ Ensure proper database drivers are installed
JavaScript/CSS not loading
- โ
Run
python manage.py collectstatic - โ Verify static files configuration
- โ Check browser console for errors
๐ Performance Considerations
- DevTools are designed for development only
- SQL queries are executed directly - use with caution on large datasets
- Python code execution has built-in safety measures but runs in the main process
- Consider using pagination for large result sets
- Monitor memory usage when working with large datasets
๐ Version Compatibility
| Django DevTools | Django Version | Python Version | Notes |
|---|---|---|---|
| 1.0.0 | 3.2.x | 3.8+ | LTS Support |
| 1.0.0 | 4.0.x | 3.8+ | โ Tested |
| 1.0.0 | 4.1.x | 3.8+ | โ Tested |
| 1.0.0 | 4.2.x | 3.8+ | LTS Support |
| 1.0.0 | 5.0.x | 3.10+ | โ Compatible |
| 1.0.0 | 5.1.x | 3.10+ | โ Compatible |
Note: Django 5.x requires Python 3.10+. For Python 3.8-3.9, use Django 4.2 LTS.
๐ค Contributing
We welcome contributions! Please see our Contributing Guidelines for details.
Development Process
- Fork the repository
- Create a feature branch (
git checkout -b feature/amazing-feature) - Commit your changes (
git commit -m 'Add amazing feature') - Push to the branch (
git push origin feature/amazing-feature) - Open a Pull Request
Code Style
- Follow PEP 8 for Python code
- Use Black for code formatting
- Add docstrings to all functions and classes
- Write tests for new features
Testing
# Run the full test suite
python -m pytest
# Check code style
black --check devtools/
flake8 devtools/
# Type checking
mypy devtools/
โ FAQ
Can I use DevTools in production?
No! DevTools are strictly for development environments. They provide powerful access to your database and Django internals.
How do I add custom functions to test?
Create a utils.py file in your Django app with your functions. DevTools will automatically discover them.
Can I customize the interface?
Yes! You can override templates and add custom CSS. See the Customization section.
Is my data safe?
DevTools include multiple security layers, but should only be used in development environments with trusted users.
What databases are supported?
DevTools work with any Django-supported database: PostgreSQL, MySQL, SQLite, Oracle.
Is Django 5.x supported?
Yes! DevTools are fully compatible with Django 5.0 and 5.1. Note that Django 5.x requires Python 3.10+, while older Django versions support Python 3.8+.
๐ Changelog
v1.0.0 (2024-01-XX)
- ๐ Initial release
- โจ Model exploration and data viewing
- โจ Python/SQL console
- โจ Database schema visualization
- โจ Function testing interface
- ๐ Security middleware and IP whitelisting
- ๐ฑ Responsive Bootstrap 5 interface
- โฌ๏ธ Django 5.x Support: Full compatibility with Django 5.0 and 5.1
- ๐ Python 3.12: Support for latest Python version
๐ License
This project is licensed under the MIT License - see the LICENSE file for details.
๐ฅ Authors & Credits
- Main Developer: Your Name
- Contributors: Contributors
Acknowledgments
- Thanks to the Django community for the excellent framework
- Bootstrap team for the UI components
- All contributors and testers
๐ Support
Getting Help
- ๐ Documentation: Read this README and inline documentation
- ๐ Bug Reports: GitHub Issues
- ๐ก Feature Requests: GitHub Discussions
- ๐ฌ Community: Django DevTools Discord
Reporting Issues
When reporting issues, please include:
- Django DevTools version
- Django version
- Python version
- Database type and version
- Error message and traceback
- Steps to reproduce
Professional Support
For commercial support or custom development:
- ๐ง Email: prince.gnangnon2@gmail.com
- ๐ Website: https://yourcompany.com/django-devtools
โญ If you find Django DevTools useful, please star the repository on GitHub!
๐ง Django DevTools - Making Django development more productive and enjoyable! ๐
Project details
Download files
Download the file for your platform. If you're not sure which to choose, learn more about installing packages.
Source Distribution
Built Distribution
Filter files by name, interpreter, ABI, and platform.
If you're not sure about the file name format, learn more about wheel file names.
Copy a direct link to the current filters
File details
Details for the file django_devtools_local-1.0.0.tar.gz.
File metadata
- Download URL: django_devtools_local-1.0.0.tar.gz
- Upload date:
- Size: 34.9 kB
- Tags: Source
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
87fcf27932ba0432cf9e00ffa08b0a02feb68fb55f10dacbf4fa3f24c4990dbc
|
|
| MD5 |
3318f1720370c06b7f4468e77e3e0a5d
|
|
| BLAKE2b-256 |
89e1f26c227ab085263406f13330db8522b8622470e1bf7dd29749072ede6dfe
|
File details
Details for the file django_devtools_local-1.0.0-py3-none-any.whl.
File metadata
- Download URL: django_devtools_local-1.0.0-py3-none-any.whl
- Upload date:
- Size: 37.3 kB
- Tags: Python 3
- Uploaded using Trusted Publishing? No
- Uploaded via: twine/6.1.0 CPython/3.13.2
File hashes
| Algorithm | Hash digest | |
|---|---|---|
| SHA256 |
43efdf38e691616371798402f34cbedda2ff76ec92658611b1f1bc5858f87500
|
|
| MD5 |
114b89d539f7bae116566c66531a1067
|
|
| BLAKE2b-256 |
faf80cb828deb6bb8e777209ea1cbe7f36c7a7b531f580fcb52a7b9df08e3ead
|