| 1 |
# Common Table Expressions with Django |
| 2 |
|
| 3 |
[](https://github.com/dimagi/django-cte/actions/workflows/tests.yml) |
| 4 |
[](https://badge.fury.io/py/django-cte) |
| 5 |
|
| 6 |
## Installation |
| 7 |
``` |
| 8 |
pip install django-cte |
| 9 |
``` |
| 10 |
|
| 11 |
|
| 12 |
## Documentation |
| 13 |
|
| 14 |
The [django-cte documentation](https://dimagi.github.io/django-cte/) shows how |
| 15 |
to use Common Table Expressions with the Django ORM. |
| 16 |
|
| 17 |
|
| 18 |
## Running tests |
| 19 |
|
| 20 |
``` |
| 21 |
cd django-cte |
| 22 |
uv sync |
| 23 |
|
| 24 |
pytest |
| 25 |
ruff check |
| 26 |
|
| 27 |
# To run tests against postgres |
| 28 |
psql -U username -h localhost -p 5432 -c 'create database django_cte;' |
| 29 |
export PG_DB_SETTINGS='{ |
| 30 |
"ENGINE":"django.db.backends.postgresql_psycopg2", |
| 31 |
"NAME":"django_cte", |
| 32 |
"USER":"username", |
| 33 |
"PASSWORD":"password", |
| 34 |
"HOST":"localhost", |
| 35 |
"PORT":"5432"}' |
| 36 |
|
| 37 |
# WARNING pytest will delete the test_django_cte database if it exists! |
| 38 |
DB_SETTINGS="$PG_DB_SETTINGS" pytest |
| 39 |
``` |
| 40 |
|
| 41 |
All feature and bug contributions are expected to be covered by tests. |
| 42 |
|
| 43 |
|
| 44 |
## Publishing a new verison to PyPI |
| 45 |
|
| 46 |
Push a new tag to Github using the format vX.Y.Z where X.Y.Z matches the version |
| 47 |
in [`__init__.py`](django_cte/__init__.py). |
| 48 |
|
| 49 |
A new version is published to https://test.pypi.org/p/django-cte on every |
| 50 |
push to the *main* branch. |
| 51 |
|
| 52 |
Publishing is automated with [Github Actions](.github/workflows/pypi.yml). |