Skip to main content

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.

Python Django License Version

โœจ 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

  1. Ensure DEBUG = True in your settings
  2. Log in with a superuser account
  3. 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:

  1. DEBUG Mode Required: Works only with DEBUG = True
  2. Authentication: Only logged-in users can access
  3. Superuser Privileges: Only superusers have access
  4. 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

Dashboard

Python Console

Console

Database Schema

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 = True in 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

  1. Fork the repository
  2. Create a feature branch (git checkout -b feature/amazing-feature)
  3. Commit your changes (git commit -m 'Add amazing feature')
  4. Push to the branch (git push origin feature/amazing-feature)
  5. 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

Acknowledgments

  • Thanks to the Django community for the excellent framework
  • Bootstrap team for the UI components
  • All contributors and testers

๐Ÿ“ž Support

Getting Help

Reporting Issues

When reporting issues, please include:

  1. Django DevTools version
  2. Django version
  3. Python version
  4. Database type and version
  5. Error message and traceback
  6. Steps to reproduce

Professional Support

For commercial support or custom development:


โญ 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

django_devtools_local-1.1.1.tar.gz (39.9 kB view details)

Uploaded Source

Built Distribution

If you're not sure about the file name format, learn more about wheel file names.

django_devtools_local-1.1.1-py3-none-any.whl (41.6 kB view details)

Uploaded Python 3

File details

Details for the file django_devtools_local-1.1.1.tar.gz.

File metadata

  • Download URL: django_devtools_local-1.1.1.tar.gz
  • Upload date:
  • Size: 39.9 kB
  • Tags: Source
  • Uploaded using Trusted Publishing? No
  • Uploaded via: twine/6.1.0 CPython/3.13.2

File hashes

Hashes for django_devtools_local-1.1.1.tar.gz
Algorithm Hash digest
SHA256 467632ba40690b914d57a44b17aac0d655185843bc1b7a9c59aeb64605973189
MD5 c91754d6f15f96c8fc2704aa0747420d
BLAKE2b-256 d07c0ac7a6d2a3237f42e80cd5eee37ac6d41204a7ebcf0c8501e21cb6cad471

See more details on using hashes here.

File details

Details for the file django_devtools_local-1.1.1-py3-none-any.whl.

File metadata

File hashes

Hashes for django_devtools_local-1.1.1-py3-none-any.whl
Algorithm Hash digest
SHA256 40852263083df07a76690c7b19ea3de158debab201378ee99d329b631ca20403
MD5 cad7512dec49032f9e6308ecdc588b4b
BLAKE2b-256 5f11674815f99417834a06a7e721830c2d4966cc23040577a7e3bb394e71f2ab

See more details on using hashes here.

Supported by

AWS Cloud computing and Security Sponsor Datadog Monitoring Depot Continuous Integration Fastly CDN Google Download Analytics Pingdom Monitoring Sentry Error logging StatusPage Status page