Skip to content

lifanwar/my-base-django

Repository files navigation

Django Starter (apps/ + Tailwind)

Starter setup best practice Django:

  • apps/ all apps django start here
  • config/settings/ switch: base, dev, staging, prod
  • move env just edit in .env DJANGO_ENV=dev|staging|prod
  • frontend integration with django-tailwind, alpinejs

Tree base project

.
├── manage.py
├── shell.nix
├── apps/
├── theme/
├── static/
└── config/
    └── settings/
        ├── __init__.py
        ├── base.py
        ├── dev.py
        ├── staging.py
        └── prod.py

Switch Environment

Rename env.example to .env

DJANGO_ENV=prod/dev/staging

Make New App (in apps/)

python manage.py startapp yournewapps apps/yournewapps

or simply in nixos:

nix-shell

Note: nix-shell automatically creates a Python virtual environment in the venv folder and activates it.

Then:

startapp <appname>    # python manage.py startapp <appname> apps/<appname>
tw-install            # python manage.py tailwind install
tw-watch              # python manage.py tailwind start
run                   # python manage.py runserver 0.0.0.0:8000

sign up yournewapps in: LOCAL_APPS ( config/settings/base.py):

LOCAL_APPS = [
    "apps.yournewapps"
]

Update file apps in: apps.yournewapps.app.py

name = 'yournewapps'

To:

name = 'apps.yournewapps'

Instalation Django + tailwindcss built in

Install:

pip install -r requirements.txt

tailwindcss apps in

THIRD_PARTY_APPS = [
    "tailwind",
    "theme",
]

Init + install + run Tailwind:

python manage.py tailwind install
python manage.py tailwind start

Load Tailwind di Template

in templates (ex: templates/base.html):

{% load tailwind_tags %}
{% tailwind_css %}

Run Server

python manage.py runserver

About

No description, website, or topics provided.

Resources

Stars

Watchers

Forks

Releases

No releases published

Packages

 
 
 

Contributors