/Django-Template

An awesome way to kickstart your Django projects!

Primary LanguagePythonMIT LicenseMIT

Logo

Django Template

An awesome way to kickstart your Django projects!
Report Bug · Request Feature


Contributors Forks Stargazers Issues MaIT License


Table of Contents

  1. About The Project
  2. Getting Started
  3. Usage
  4. Contributing
  5. License

About The Project

Managing your Django project and all its dependencies can be a nightmare. This also includes managing dependencies in virtual environments, securing your SECRET KEY, adding files to .gitignore, running code style validations and what not.

Why not simplify this tedious and repetetive work?

With this objective in mind, I created Django Template, a simple and minimalistic django project template that fits all your requirements.

Getting Started

Simply click on Use this template button on top to get started. Go ahead and choose a cool name for your project. Clone the newly created repository and continue with the following steps.

Prerequisites

This project is optimized to run on Linux Environments. Tests for Windows and Mac are still in progress.

Installation

After getting a local copy on your system, run the following commands based on your role.

  • Making a new Django Project

    If you are a developer who is just starting with a new project, simply run

    make project

    A prompt will ask you to enter a valid project name before continuing. This command will setup your virtual environment, secret keys and all the basic dependencies required by a django project.

    Note: While developing, it is advisable to enter your virtual environment for proper configuration and better control. To enter a virtual environment, use

    . bin/activate

    To deactivate the environment, simply use deactivate command

    deactivate
    

    Alternatively, if you prefer a finer control over your project creation,you can use the following commands

    • Install all project dependencies and create virtual environment

      make install
    • Make django project using django-admin

      django-admin startproject --template=./etc/structure ${project-name} .

      Replace ${project-name} with the name of Django project as per your wish. Also, you can customize the template for your project,according to your need.

    Note: This directory will now function as your root django folder. Upon creation of a project, a folder named ${project-name} and manage.py will appear at the root.


  • Running an existing Django Project

    If the repository already contains a django project, you can simply install the requirements and run the project.

    To install all the dependencies, use

    make install

Usage

You can use make commands to perform various operations on your django project.

  1. Start django server on port 8000. You can customize it by editing PORT in Makefile.

    make run
  2. Apply database migrations

    make migrate
  3. Clear database records.

    make flush

    Note: Media files will not be deleted using this command

  4. Update project requirements (useful for deployment)

    make freeze

    This command will add all your project dependencies to etc/requirements.txt, making it very easy for deployment.

  5. Running Django Testcases

    make test
  6. Check for proper formatting and import style using black and isort

    make format

Contributing

Contributions are what make the open source community such an amazing place to be learn, inspire, and create. Any contributions you make are greatly appreciated.

  1. Fork the Project
  2. Create your Feature Branch (git checkout -b feature/AmazingFeature)
  3. Commit your Changes (git commit -m 'Add some AmazingFeature')
  4. Push to the Branch (git push origin feature/AmazingFeature)
  5. Open a Pull Request

License

Distributed under the MIT License. See LICENSE for more information.