A boilerplate project for Django to fast initialization.
All backend code follows PEP8 style guidelines.
Useful Links
- Clone/pull/download this repository.
- Create virtual environment and install dependencies.
- Configure the env variables. Use src/.env for development. For production, set them in the OS.
- Rename the project.
#Syntax
python manage.py rename <current_project_name> <new_project_name>
#Example
python manage.py rename current_project my_project
- Generate Secret Key Use this key as your SECRET_KEY. Replace SECRET_KEY in 'src/.env'.
- Method 1
python manage.py shell
from django.core.management.utils import get_random_secret_key
print(get_random_secret_key())
- Method 2
python -c "from django.core.management.utils import get_random_secret_key; print(get_random_secret_key())"
python -m venv venv
venv\Scripts\activate
pip install -r requirements.txt
pip freeze > requirements.txt
- Django: A Python based web framework.
- pillow: A library to manage images in Django Apps.
- django-debug-toolbar: To manage debugging in development mode.
- psycopg2: for managing postgres db
- dj-database-url: for postgres db url
gunicorn: Server whitenoise: Simplified static file serving
- python==3.9
- Django==3.2
- django-crispy-forms - A Library to integrate Django forms with Bootstrap.
- django-allauth - Used for authentication.
- django-countries - Used to list countries.
pip install django-crispy-forms, django-allauth, django-countries
Included in requirements.txt - external installation not required.
SQLite database is used for development. It is configured automatically by Django.
With Postgres, create a database named testdb
createdb testdb
Make sure to include the database credentials in env_file.py
From the project directory to run the server, execute:
python manage.py migrate
python manage.py runserver
- Uncomment '.env' inside .gitignore so that .env file is not uploaded in the repository.
- Edit '.vscode/settings.json' ss per your choices.
- You must generate a new secret key for your project.
- Make sure to set environmental variable DEBUG=False.
Himel Das
This boilerplate is an extension of the boilerplate by justdjango. I studied the YouTube videos on this topic by JustDjango YouTube channel while creating this boilerplate. Thanks to justdjango for creating such an amazing boilerplate and step by step tutorial.
For special commands and detailed note refer to the following links: