Skip to content

Latest commit

 

History

History
48 lines (35 loc) · 1.7 KB

django_walktrought.md

File metadata and controls

48 lines (35 loc) · 1.7 KB

Django Walkthrough

A basic checklist for getting started with Django:

  1. we assume you have already a virtual environment with django installed.
  2. activate your venv: conda activate my_env
  3. create a new django project: django-admin startproject my_project
  4. create a new django app: python manage.py startapp my_app
  5. register the app in setting.py INSTALLED_APPS = [
  6. remove secret key into .env
  7. create a urls.py file in your app and link it to main project urls.py with include
  8. register your app name in such urls.py file app_name = 'my_app'
  9. update settings.py accordingly with the location of your static and templates folder if needed
  10. run migrations
  11. create a superuser
  12. create your first model
  13. make migrations and run migrations
  14. add custom custom errors templates
  15. align or customize admin section

About the django workspace and virtual env you are using

I recommend you to include in the virtual environment:

  1. 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']

  1. pip install pylint-django

Also, include in the workspace (root):

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