Cheat Sheet

Basic Django app setup

# 1. Install all the basic packages This packages includes - Django - DRF - Django extensions - Django crispy forms - Django Register - Django HTMX - Django filters - Ruff ``` asgiref==3.9.1 asttokens==3.0.0 confusable-homoglyphs==3.3.1 decorator==5.2.1 Django==5.2.4 django-crispy-forms==2.4 django-extensions==4.1 django-filter==25.1 django-htmx==1.23.2 django-registration==5.2.1 djangorestframework==3.16.0 executing==2.2.0 ipdb==0.13.13 ipython==9.4.0 ipython_pygments_lexers==1.1.1 jedi==0.19.2 matplotlib-inline==0.1.7 parso==0.8.4 pexpect==4.9.0 prompt_toolkit==3.0.51 ptyprocess==0.7.0 pure_eval==0.2.3 Pygments==2.19.2 sqlparse==0.5.3 stack-data==0.6.3 traitlets==5.14.3 wcwidth==0.2.13 ``` Save this list in a `requirements.txt` file and run the installation command: ``` pip install -r requirements.txt ``` # 2. Create the django project ``` django-admin startproject <project-name> <project-folder> ``` # 3. Update the settings.py file to include all the third party installed apps: ``` DJANGO_APPS = [ "django.contrib.admin", "django.contrib.auth", "django.contrib.contenttypes", "django.contrib.sessions", "django.contrib.messages", "django.contrib.staticfiles", ] THIRD_PARTY_APPS = [ "rest_framework", "django_extensions", "crispy_forms", "django_htmx", "django_filters", ] CUSTOM_APPS = [] INSTALLED_APPS = DJANGO_APPS + THIRD_PARTY_APPS + CUSTOM_APPS MIDDLEWARE = [ "django.middleware.security.SecurityMiddleware", "django.contrib.sessions.middleware.SessionMiddleware", "django.middleware.common.CommonMiddleware", "django.middleware.csrf.CsrfViewMiddleware", "django.contrib.auth.middleware.AuthenticationMiddleware", "django.contrib.messages.middleware.MessageMiddleware", "django.middleware.clickjacking.XFrameOptionsMiddleware", "django_htmx.middleware.HtmxMiddleware", ] ```