~nora/django-template

Template to start a Django/Tailwind/Htmx project
Update dependencies
accounts: fix imports
Add alpine.js framework

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

Install dependencies in a virtual environment.

poetry install

Initialize database and create super user.

poetry run python manage.py migrate
poetry run python manage.py createsuperuser

Run server (webpages reloaded on change).

poetry run python manage.py runserver

Run tailwind (stylesheet updated on change).

poetry run tailwindcss -c theme/tailwind/config.js -i theme/tailwind/style.css -o theme/static/css/style.css --watch

#Deploying

Generate dependencies file for production.

poetry export -f requirements.txt --output requirements.txt

Compile and minimise stylesheet for production.

poetry run tailwindcss -c theme/tailwind/config.js -i theme/tailwind/style.css -o theme/static/css/style.css --minify

Then follow https://nora.nckm.eu/django-deploy.html.

#Translating

Create a new language file or update the existing one.

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

poetry run python manage.py compilemessages -l fr

Make and compile all language files at once.

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

#Testing

Execute all tests.

poetry run python manage.py test