Skip to content

Compatibility for Django 2.0/2.1/2.2 and Debian/bullseye

Steven McDonald requested to merge stevenmcdonald/repomaker:django-update into master

Updates to work with Django 2.0/2.1/2.0 @eighthave

django-hvad was never updated for django 2.0. There's another project called django-parler that's supposedly a drop in replacement, but it does things differently enough, that it didn't work with the class hierarchy in repomaker. It doesn't like abstract base classes, for example.

So, I went with django-modeltranslation. It does things quite a bit differently, translations are stored language suffixed columns instead of sub-objects, and it uses the current language in Django to pick the right ones, which means using the override context manager and apply helper from django.utils.translation when you want to do something in a different language than the user's browser requested, or when not in a web context.

Caveats:

  • the biggest one is that I didn't have time for a data migration. With these changes, it can generate a migration from the old schema to the new one, but I assume applying it would lose data. I've replaced that initial migration with a new one to prevent people from blindly applying a migration that loses data, but I'm not sure the best thing to do here. Ideally, we'd have a data migration, but I don't think I have time to make one now.
  • the packaged version of bleach in debian bullseye doesn't work, I didn't investigate, but the unit tests that test the clean helper fail with that version, I just used a version installed with pip
  • All the test pass, and the single user web UI works from what I tested, but I didn't get around to running the GUI at all, so it's possible I missed some stuff there
  • the get_available_languages implementation in the App model feels a little hacky... I replaced it with a field that just stores what translations have been input as a placeholder when I started working, but it seems to have done the job
  • Django >=3.0 will need django-background-tasks to be updated to support Django newer than 2.2

I don't think I would have been able to do this without the extensive unit tests in the project, so I'm glad they're there.

Edited by Hans-Christoph Steiner

Merge request reports