A basic checklist for getting started with Django:
- we assume you have already a virtual environment with django installed.
- activate your venv:
conda activate my_env
- create a new django project:
django-admin startproject my_project
- create a new django app:
python manage.py startapp my_app
- register the app in setting.py
INSTALLED_APPS = [
- remove secret key into .env
- create a
urls.py
file in your app and link it to main project urls.py withinclude
- register your app name in such
urls.py
fileapp_name = 'my_app'
- update
settings.py
accordingly with the location of your static and templates folder if needed - run migrations
- create a superuser
- create your first model
- make migrations and run migrations
- add custom custom errors templates
- align or customize admin section
I recommend you to include in the virtual environment:
pip install python-dotenv
in order to manage the .env file and secrets in your project.
The usage is as follows:
from dotenv import load_dotenv, find_dotenv
load_dotenv(find_dotenv())
SECRET_KEY = os.environ['SECRET_KEY']
pip install pylint-django
Also, include in the workspace (root):
- a custom python file
.pylintrc
for each project.
run in terminal:pylint --generate-rcfile > .pylintrc
then I suggest you to add:
in [MASTER] section:
load-plugins=pylint_django
django-settings-module=myprojectname.settings
in [BASIC] section:
docstring-min-length=10
Please also note that .2 and .3 are mostly to avoid VS CODE stressing you with non-existent warnings and errors.