This project is a template for creating Django-based web applications. It provides a well-organized and modular structure, enabling developers to build scalable, maintainable, and feature-rich applications efficiently. The template supports best practices for application logic, configurations, testing, and deployment.
- Modular App Design: A directory structure that separates logic for better scalability.
- Environment-Specific Settings: Separate configuration files for development and production environments.
- Static and Media File Management: Proper handling of CSS, JavaScript, images, and user-uploaded files.
- Pre-configured Docker Support: Containerized environment for consistent deployment.
- Automated Scripts: Ready-to-use scripts for starting the development server, running migrations, and deploying.
- Testing Setup: Unit and integration test examples.
django-project-structure-template/
├── README.md # Project overview and instructions
├── LICENSE # Licensing information
├── .gitignore # Files and directories to be ignored by Git
├── requirements.txt # Python dependencies
├── manage.py # Django's command-line utility
├── project_name/ # Main project directory
│ ├── __init__.py # Marks this directory as a Python package
│ ├── settings.py # Project settings
│ ├── urls.py # URL configuration
│ ├── wsgi.py # WSGI application for deployment
│ ├── asgi.py # ASGI application for async support
├── apps/ # Custom Django applications
│ ├── __init__.py # Marks this directory as a Python package
│ ├── app_name/ # Example app directory
│ ├── __init__.py
│ ├── admin.py # Admin panel configuration
│ ├── apps.py # App-specific configurations
│ ├── models.py # Database models
│ ├── tests.py # Unit tests
│ ├── views.py # View functions or classes
│ ├── urls.py # App-specific URL configurations
│ ├── templates/ # HTML templates
│ ├── static/ # Static files (CSS, JS, images)
│ ├── migrations/ # Database migrations
├── static/ # Global static files
├── media/ # Uploaded media files
├── templates/ # Global templates
├── configs/ # Configuration files
│ ├── dev_settings.py # Development-specific settings
│ ├── prod_settings.py # Production-specific settings
├── scripts/ # Custom management scripts
│ ├── start_dev.sh # Script to start the development server
│ ├── deploy.sh # Deployment script
├── tests/ # Test cases
│ ├── integration_tests.py # Integration tests
│ ├── unit_tests.py # Unit tests
├── docker/ # Docker configuration
│ ├── Dockerfile # Dockerfile for building the image
│ ├── docker-compose.yml # Docker Compose configuration
├── logs/ # Log files
├── docs/ # Documentation
│ ├── index.md # Documentation index
│ ├── api_reference.md # API reference documentation
- Python: Version 3.8 or higher.
- Django: Listed in
requirements.txt
. - Docker: For containerized deployment (optional).
- PostgreSQL/MySQL/SQLite: Supported databases.
- Clone the repository:
git clone https://github.com/your-username/django-project-structure-template.git
- Navigate to the project directory:
cd django-project-structure-template
- Create a virtual environment and activate it:
python -m venv venv source venv/bin/activate # On Windows: venv\Scripts\activate
- Install dependencies:
pip install -r requirements.txt
- Run Migrations: Set up the database schema.
python manage.py migrate
- Run the Development Server:
python manage.py runserver
- Create a Superuser:
python manage.py createsuperuser
- Access the Admin Panel:
Visit
http://127.0.0.1:8000/admin
. - Run Tests:
python manage.py test
- Build and run the Docker container:
docker-compose up --build
- Access the application at
http://localhost:8000
.
Contributions are welcome! Please fork the repository and submit a pull request with your changes.
This project is licensed under the terms specified in the LICENSE
file.
For questions or feedback, please contact [Your Name] at [[email protected]].