~nora/django-template

Template to start a Django/Tailwind/Htmx/Alpine project
core: fix htmx form reset
Update tailwindcss 4.0.3, alpinejs 3.14.8, htmx 2.0.4
Update dependencies and migrate to uv and ruff

refs

main
browse  log 

clone

read-only
https://git.sr.ht/~nora/django-template
read/write
git@git.sr.ht:~nora/django-template

You can also use your local clone with git send-email.

#Django template

This is a template to start a Django/Tailwind/Htmx/Alpine project.

#Features

This template includes the following features.

  1. Templates
    • Home
    • Contact
    • Privacy
  2. Authentication
    • Login
    • Signup
    • Profile
  3. Administration
  4. Database
  5. Internationalisation
  6. Emailing
  7. Logging
  8. Tests
  9. Documentation

#Starting a new project from template

Clone template repository, modify some files, push modification on new repository.

git clone git@git.sr.ht:~nora/django-template new-project
cd new-project
rm -rf .git
# edit pyproject.toml and README.md
git init
git add .
git commit -m"Initial commit"
git remote add origin git@git.sr.ht:~nora/new-project
git push -u origin main

#Building and running

Create configuration file in config/.env (example in config/.env.dist).

Initialize database and create super user.

uv run python manage.py migrate
uv run python manage.py createsuperuser

Run server (webpages reloaded on change).

uv run python manage.py runserver

Run tailwind (stylesheet updated on change).

uv run tailwindcss -i theme/tailwind/style.css -o theme/static/css/style.css --watch

#Deploying

Install dependencies.

uv sync

Compile and minimise stylesheet for production.

uv run tailwindcss -i theme/tailwind/style.css -o theme/static/css/style.css --minify

Then follow https://nora.nckm.eu/django-deploy.html launching commands in the virtual environment with uv run.

#Translating

Create a new language file or update the existing one.

uv run python manage.py makemessages -l fr

Edit the file in locale/fr/LC_MESSAGES/django.po.

Compile the file to locale/fr/LC_MESSAGES/django.mo.

uv run python manage.py compilemessages -l fr

Make and compile all language files at once.

uv run python manage.py makemessages -a
uv run python manage.py compilemessages

#Testing

Execute all tests.

uv run python manage.py test
Do not follow this link