DjangoMate (dm
) is a powerful CLI tool designed to simplify and enhance Django project management. It brings several helpful features to streamline common operations, enforce security best practices, and ensure code quality in Django-based projects. This tool is aimed at developers who want to be more productive by automating repetitive tasks and integrating essential development tools.
-
Effortless Django Commands 🛠️:
- Simplifies commonly used Django commands like
runserver
,migrate
, andtest
. - Reduces command complexity by offering shorthand versions of Django's long management commands.
- Simplifies commonly used Django commands like
-
Automated Project Setup ⚙️:
- A single command to initialize Django projects with optional Docker and Kubernetes configurations.
- Sets up
INSTALLED_APPS
and other configurations without manually editing thesettings.py
.
-
Static Application Security Testing (SAST) 🔒:
- Integrated with tools like Bandit for security checks on the codebase.
- Quickly scans your code for potential security issues.
-
Code Formatting 🎨:
- Automates the process of running code formatters like Black and linters like Flake8 to ensure consistent code quality.
- Can be invoked with a single command.
-
Pre-commit Hook Setup 🔄:
- Sets up pre-commit hooks to ensure no insecure or poorly formatted code gets committed.
- Automatically runs Bandit, Black, and Flake8 on every commit to ensure security and code quality are enforced at the source.
-
Clone the repository:
git clone https://github.com/yahialm/django-simplifier.git
-
Navigate to the project directory:
cd django-simplifier
-
Install the tool:
go install
-
Ensure that the
dm
command is in yourPATH
.
Once installed, you can access the DjangoMate tool using the dm
command. Below are the available subcommands and their explanations:
-
Run the Django Development Server 🖥️:
dm serve
This command simplifies running the Django development server (
python manage.py runserver
). -
Migrations 📦:
dm mig dm mkmig dm shmig
These commands handle Django migrations (
migrate
,makemigrations
, andshowmigrations
). -
Database Shell 💾:
dm dbsh
This command opens the Django database shell (
python manage.py dbshell
). -
Django Shell 🐚:
dm sh
This command opens the Django interactive shell (
python manage.py shell
). -
Run Tests ✅:
dm test
Run your project's tests easily (
python manage.py test
). -
Create Superuser 👤:
dm su
Creates a new superuser for the Django admin panel (
python manage.py createsuperuser
). -
Create a New App 📱:
dm app <app_name>
Creates a new Django app and automatically adds it to
INSTALLED_APPS
insettings.py
.
-
Scan for Security Vulnerabilities 🔍:
dm scan
Runs Bandit, a security analysis tool to find common security issues in your Python codebase.
-
Format Code ✨:
dm format
Automatically formats your Python code using Black and checks it with Flake8 to ensure compliance with style guides.
- Set up Pre-commit Hooks 🔗:
This command sets up a pre-commit hook to automatically run Bandit, Black, and Flake8 before any commit. It ensures no insecure or badly formatted code is committed to the repository.
dm precommit-setup
-
Initialize your Django project 🆕:
dm setup
-
Run the development server
▶️ :dm serve
-
Create new apps ✏️:
dm app blog
-
Run security and code checks 🔧:
dm scan dm format
-
Set up pre-commit hooks 🔧:
dm precommit-setup
-
Commit code 💾:
git add . git commit -m "Added new features"
The pre-commit hooks will automatically scan the code for security vulnerabilities and ensure it is formatted correctly.
Contributions are welcome! Feel free to submit issues or pull requests on GitHub. The goal of this project is to make Django development faster, more secure, and less error-prone for everyone.
- Fork the repository.
- Create a new feature branch.
- Submit a pull request with a detailed explanation of your changes.
This project is licensed under the MIT License.