Development
Creating a Django project
How I would create a new project to work on django-ditto’s code.
Check out django-ditto
Create an empty directory at the same level as django-ditto, like
django-ditto-devproject.On the command line do the following:
cd django-ditto-devproject uv init rm hello.py # Created by uv init but we don't need it uv add --editable ./../django-ditto uv run django-admin startproject devsite .
In
devsite/settings.pyadd these toINSTALLED_APPS:"sortedm2m", "taggit", "ditto.core", "ditto.flickr", "ditto.lastfm", "ditto.pinboard", "ditto.twitter",
On the command line o:
uv run manage.py migrate
In
devproject/urls.pyadd these tourlpatterns:path(r"flickr/", include("ditto.flickr.urls")), path(r"lastfm/", include("ditto.lastfm.urls")), path(r"pinboard/", include("ditto.pinboard.urls")), path(r"twitter/", include("ditto.twitter.urls")), path(r"", include("ditto.core.urls")),
On the command line do:
uv run manage.py runserver
You can then visit http://127.0.0.1:8000 to view the Django-spectator front page. Use
uv run manage.py createsuperuseras normal with a Django project to create a superuser.
pre-commit
pre-commit will run flake8, black, isort and prettier across all files on commit. I think you just need to do this first:
$ pre-commit install
Tests
Run tests with tox. Install it with uv:
$ uv tool install tox --with-uv
You’ll need to have all versions of python available that are tested against (see tox.ini). This might mean deactivating a virtualenv if you’re using one with devproject/. Then run all tests in all environments like:
$ tox
To run tests in only one environment, specify it. In this case, Python 3.13 and Django 4.2:
$ tox -e py313-django51
To run a specific test, add its path after --, eg:
$ tox -e py313-django51 -- tests.flickr.test_views.HomeViewTests.test_home_templates
Running the tests in all environments will generate coverage output. There will
also be an htmlcov/ directory containing an HTML report. You can also
generate these reports without running all the other tests:
$ tox -e coverage
Other notes for development
Environment
Create a virtual environment using uv:
$ uv sync
This can be used in your text editor if required. It will also enable building the documentation (see below).
This is currently the only thing the uv.lock file is present for. (Should
we actually gitignore it?)
Documentation
If you have done uv sync then sphinx
should already be installed.
$ cd docs
$ uv run make html
Packaging
Replace 4.0.1 with current version number:
Put new changes on
main.Set version number in
src/ditto/__init__.pyRebuild documentation (which includes the version number).
Update
CHANGELOG.md.Commit code.
git tag -a 4.0.1 -m 'version 4.0.1'git push --tagsuv builduv publish dist/django_ditto-4.0.1*