Skip to content

Development Tips

Niklas Mohrin edited this page Nov 24, 2024 · 10 revisions

Management Commands

  • run manage.py run to start the django development server
  • Before opening a pull request, running these could be helpful (otherwise, our CI will fail)
    • run manage.py test to run the test suite
    • run manage.py lint to run the linter
    • run manage.py format to run the code formatter
  • run manage.py migrate whenever you pull changes with new migrations
  • run manage.py makemigrations whenever you change any models
  • run manage.py reload_testdata to throw away the database and reload the test_data
  • run manage.py scss --watch if you want to compile your stylesheets automatically. (otherwise this happens only once on manage.py run)
  • run manage.py shell_plus to interactively test python code
    • in contrast to shell, this automatically imports e.g. all models.
  • use manage.py dump_testdata for creating a new test_data.json
  • run manage.py translate as a shortcut for makemessages for the required German translation with appropriate arguments

Git

We have a list of commits that clutter git blame history in .git-blame-ignore-revs. You can pass --ignore-revs-file .git-blame-ignore-revs to git in order to ignore these commits. You probably want to set up your git to automatically do this, using:

git config blame.ignoreRevsFile .git-blame-ignore-revs

Linting and Code formatting

It probably makes sense to integrate our linter, pylint, and our code formatter, black, into your IDE. You can also set up precommit hooks to automatically run these when committing.

Translation

Use poedit to edit the translation files

Automatic Environment Activation

To automatically activate the nix develop environment when entering the EvaP directory, you can install direnv and nix-direnv. Afterwards, create the file .envrc with the following contents:

use flake

Extra Packages

To install additional packages in the nix develop environment, use the extraPackages and extraPythonPackages arguments when importing shell.nix in flake.nix. Find the packages you are looking for at https://search.nixos.org/packages. Make sure to not include these changes in your git commits. You can use git update-index --assume-unchanged, if you know what you are doing.