New 5.0 behavior? Storing translated string in database (Solved)

I have this code, and when tox testing it on Django 3.2 → 4.2, it works swimmingly

    def test_store_untranslated_string(self):
        lang = get_language()
        verb = _('English')

        self.assertEqual(verb, 'Anglais')
        action.send(self.user1, verb=verb, action_object=self.comment,
          , timestamp=self.testdate)

Source: django-activity-stream/actstream/tests/ at main · justquick/django-activity-stream · GitHub

Testing this on Django 5.0 however, it’s failing at


So, presumably, this is new 5.0 behavior where the string is being stored translated into the database now, whereas previous versions stored the string in the LANGUAGE_CODE specified language? Does anyone have any thoughts or insights here? I’m just trying to bring this package up to supporting Django 5.0, and I’m 99% it will support 5.0 without changes, so just need the tests passing :thumbsup:

Hello @wgordon17!

If you believe you’ve identified a regression in 4.2 < Django <= 5.0 you should try bisecting the exact commit that introduced the change in behavior. It might help you self-answer your question and determine if it’s an actual bug.


Excellent, thanks for the pointer @charettes! Reading the doc, I’m assuming that I should be checking out the Django repository directly, and contributing the regression test there?

yep, it will be the easiest way to bisect the problematic change. I suggest you create a new test app in the tests directory called something like test_translated_strings and create your models and tests in there. From there git bisect should be able to checkout different commits between 4.2 and 5.0 while preserving your untracked files and you should be able to use ./test/ test_translated_strings.

Thanks again @charettes! So, based on your input and a lot of digging, I’ve discovered the culprit was a change in behavior to lazy (Made proxy class in lazy() prepare eagerly. · django/django@ae94077 · GitHub) where the internal properties changed (yes, I know, don’t use private attributes). So it was these lines (django-activity-stream/actstream/ at main · justquick/django-activity-stream · GitHub), which I didn’t realize were responsible for the change in translated → untranslated. And the _proxy___args attribute no longer exists in Django 5.0, and is instead replaced with _args.

Ahh nice find! I see that you filed a corrective already so everything should be good going forward. Thank you for taking the time to triage the issue yourself.