Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension


Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
6 changes: 3 additions & 3 deletions .github/TESTING.md
Original file line number Diff line number Diff line change
Expand Up @@ -26,7 +26,7 @@ This repository uses GitHub Actions to automatically run tests and generate cove

#### Django HTMX Alpine (Python)
- **Python Version:** 3.10
- **Dependencies:** Installed via Poetry
- **Dependencies:** Installed via uv
- **Tests:** pytest-django with coverage
- **Coverage:** Uploaded to Codecov with flag `django-python`
- **Artifacts:** HTML coverage report (30 days retention)
Expand Down Expand Up @@ -118,8 +118,8 @@ open htmlcov/index.html
### Django HTMX Alpine (Python)
```bash
cd frameworks/htmx/django-htmx-alpine
poetry install --with dev
poetry run pytest --cov --cov-report=html
uv sync --extra dev
uv run pytest --cov --cov-report=html
open htmlcov/index.html
```

Expand Down
17 changes: 8 additions & 9 deletions .github/workflows/test-coverage.yml
Original file line number Diff line number Diff line change
Expand Up @@ -62,28 +62,27 @@ jobs:
steps:
- uses: actions/checkout@v4

- name: Install uv
uses: astral-sh/setup-uv@v5
with:
enable-cache: true

- name: Set up Python
uses: actions/setup-python@v5
with:
python-version: '3.10'
cache: 'pip'

- name: Install Poetry
run: |
curl -sSL https://install.python-poetry.org | python3 -
echo "$HOME/.local/bin" >> $GITHUB_PATH

- name: Install dependencies
run: |
poetry install --with dev
uv sync --extra dev

- name: Run migrations
run: |
poetry run python manage.py migrate --noinput
uv run python manage.py migrate --noinput

- name: Run tests with coverage
run: |
poetry run pytest --cov --cov-report=xml --cov-report=term
uv run pytest --cov --cov-report=xml --cov-report=term

- name: Upload coverage to Codecov
uses: codecov/codecov-action@v4
Expand Down
18 changes: 9 additions & 9 deletions frameworks/htmx/django-htmx-alpine/README.md
Original file line number Diff line number Diff line change
Expand Up @@ -9,19 +9,19 @@ A live demo can be seen [here](https://django-htmx-alpine.nicholasmoen.com/).
## Setup Instructions

- Create a virtualenv and install the required dependencies
- Using [Poetry](https://python-poetry.org/docs/) (recommended):
- Create a virtualenv and install the required dependencies
- Dev/Testing environment: `poetry install`
- Production environment: `poetry install --no-dev`
- Activate the virtualenv
- `poetry shell`
- Using [uv](https://docs.astral.sh/uv/) (recommended):
- Install dependencies and create a virtualenv automatically
- Dev/Testing environment: `uv sync --extra dev`
- Production environment: `uv sync`
- Run commands in the virtualenv
- `uv run python manage.py <command>`
- Using [virtualenvwrapper](https://virtualenvwrapper.readthedocs.io/en/latest/):
- Create a new virtualenv
- `mkvirtualenv django-htmx-alpine`
- Activate the virtualenv
- `workon django-htmx-alpine` -or- `source ~/[your_virtualenv_dir]/bin/activate`
- From the project's root folder (`django_htmx_alpine`), install the required dependencies
- `pip install -r requirements.txt`
- `pip install -e ".[dev]"`
- Running tests
- From the project's root folder, run `npm install`.
- To run unit tests, run `npm run jest`.
Expand All @@ -31,7 +31,7 @@ A live demo can be seen [here](https://django-htmx-alpine.nicholasmoen.com/).
`from django.core.management import utils
print(utils.get_random_secret_key())`

- Run `manage.py migrate` to generate a database.
- Run `manage.py runserver` to start the development server
- Run `uv run python manage.py migrate` to generate a database.
- Run `uv run python manage.py runserver` to start the development server

- If you want the HTMX weather demo to work, update `settings.WEATHER_API_KEY` with an API key from [OpenWeather](https://openweathermap.org/api) using the 'Current Weather Data' API.
880 changes: 0 additions & 880 deletions frameworks/htmx/django-htmx-alpine/poetry.lock

This file was deleted.

52 changes: 33 additions & 19 deletions frameworks/htmx/django-htmx-alpine/pyproject.toml
Original file line number Diff line number Diff line change
@@ -1,25 +1,39 @@
[tool.poetry]
[build-system]
requires = ["setuptools>=61.0"]
build-backend = "setuptools.build_meta"

[project]
name = "django-htmx-alpine"
version = "0.1.0"
description = "A sandbox for using Django with HTMX"
authors = ["Nicholas Moen <arcanemachine@tutanota.com>"]
license = "MIT"
readme = "README.md"
license = {text = "MIT"}
authors = [
{name = "Nicholas Moen", email = "arcanemachine@tutanota.com"}
]
requires-python = ">=3.8"
dependencies = [
"Django>=3.2.2",
"django-simple-captcha>=0.5.14",
"requests>=2.25.1",
"gunicorn>=20.1.0",
"Pillow>=10.0.0",
]

[tool.poetry.dependencies]
python = "^3.8"
Django = "^3.2.2"
django-simple-captcha = "^0.5.14"
requests = "^2.25.1"
gunicorn = "^20.1.0"
Pillow = "^10.0.0"
[project.optional-dependencies]
dev = [
"beautifulsoup4>=4.9.3",
"ipython>=7.25.0",
"pytest>=7.0.0",
"pytest-cov>=4.0.0",
"pytest-django>=4.5.0",
]

[tool.poetry.group.dev.dependencies]
beautifulsoup4 = "^4.9.3"
ipython = "^7.25.0"
pytest = "^7.0.0"
pytest-cov = "^4.0.0"
pytest-django = "^4.5.0"
[tool.setuptools]
# Django project with apps, not a traditional package
py-modules = []

[build-system]
requires = ["poetry-core>=1.0.0"]
build-backend = "poetry.core.masonry.api"
[tool.setuptools.packages.find]
# Include Django apps
include = ["todos*", "weather*", "users*", "root*"]
where = ["."]
2 changes: 1 addition & 1 deletion frameworks/htmx/django-htmx-alpine/tasks/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@
from django.http import HttpResponse
from django.views.decorators.http import require_http_methods
from django.shortcuts import get_object_or_404, render
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from urllib.parse import unquote as urllib_parse_unquote

from .models import Task
Expand Down
4 changes: 2 additions & 2 deletions frameworks/htmx/django-htmx-alpine/users/tests.py
Original file line number Diff line number Diff line change
Expand Up @@ -56,7 +56,7 @@ def test_login_view_accessible(self):

def test_logout_view_accessible(self):
"""Test that logout view is accessible"""
response = self.client.get('/users/logout/')
response = self.client.post('/users/logout/')
# Should redirect after logout
self.assertIn(response.status_code, [200, 302])

Expand Down Expand Up @@ -90,7 +90,7 @@ def test_user_cannot_login_with_wrong_password(self):
def test_user_logout(self):
"""Test that user can logout"""
self.client.login(username='testuser', password='testpass123')
response = self.client.get('/users/logout/')
response = self.client.post('/users/logout/')
# After logout, user should not be authenticated
self.assertIn(response.status_code, [200, 302])

Expand Down
2 changes: 1 addition & 1 deletion frameworks/htmx/django-htmx-alpine/users/views.py
Original file line number Diff line number Diff line change
Expand Up @@ -8,7 +8,7 @@
from django.shortcuts import render
from django.urls import reverse
from django.utils.decorators import method_decorator
from django.utils.translation import ugettext_lazy as _
from django.utils.translation import gettext_lazy as _
from django.views.decorators.cache import never_cache
from django.views.generic import CreateView

Expand Down
Loading
Loading