Skip to content

Development Tips

Johannes Wolf edited this page Sep 2, 2024 · 9 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

Vagrant VM

  • If the vagrant VM does not boot, open the virtualbox gui and click on the "Show" button. If you always want this window to open: Search for some commented-out lines in the vagrant file and uncomment them.
  • We use pylint, which is quite resource heavy. It might get stuck with the 1GB of RAM the VM allocates by default. You might want to increase this for pylint to run successful in the VM.

Testing EvaP running behind a full webserver (apache) instead of the django development server

There's an apache server installed in the vagrant vm. It is running by default and accessible on the host machinne at http://localhost:8001:

  • you have to run service apache2 reload when python code changes
  • you have to run manage.py collectstatic when static files change
  • easiest way to reroute console output to apache error logs: put sys.stdout = sys.stderr into manage.py
  • access logs via: sudo su -c "less /var/log/apache2/evap_error.log"