Skip to content

This project is a template for creating Django-based web applications.

License

Notifications You must be signed in to change notification settings

sanketrs/django-project-structure-template

Repository files navigation

Django Project Structure Template

Overview

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.

Features

  • 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.

Directory Structure

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

Prerequisites

  • Python: Version 3.8 or higher.
  • Django: Listed in requirements.txt.
  • Docker: For containerized deployment (optional).
  • PostgreSQL/MySQL/SQLite: Supported databases.

Installation

  1. Clone the repository:
    git clone https://github.com/your-username/django-project-structure-template.git
  2. Navigate to the project directory:
    cd django-project-structure-template
  3. Create a virtual environment and activate it:
    python -m venv venv
    source venv/bin/activate   # On Windows: venv\Scripts\activate
  4. Install dependencies:
    pip install -r requirements.txt

Usage

  1. Run Migrations: Set up the database schema.
    python manage.py migrate
  2. Run the Development Server:
    python manage.py runserver
  3. Create a Superuser:
    python manage.py createsuperuser
  4. Access the Admin Panel: Visit http://127.0.0.1:8000/admin.
  5. Run Tests:
    python manage.py test

Docker Support

  1. Build and run the Docker container:
    docker-compose up --build
  2. Access the application at http://localhost:8000.

Contributing

Contributions are welcome! Please fork the repository and submit a pull request with your changes.

License

This project is licensed under the terms specified in the LICENSE file.

Contact

For questions or feedback, please contact [Your Name] at [[email protected]].

About

This project is a template for creating Django-based web applications.

Topics

Resources

License

Stars

Watchers

Forks