deschler / django-modeltranslation

Translates Django models using a registration approach.
BSD 3-Clause "New" or "Revised" License
1.37k stars 258 forks source link

fix: Remove deprecated test config starting from Django 5.0 #733

Closed wookkl closed 4 months ago

wookkl commented 4 months ago

Hello,

I found and resolved the issue with testing not functioning in Django 5.0 version, after seeing the issue comment.

The cause was the "TEST": {"SERIALIZE": False} option inside the _get_database_config in tests/settings.py. This option was deprecated since version 4.0 and removed in version 5.0.

Removing "TEST": {"SERIALIZE": False} leads to an error related to GroupTranslationOptions in tests/translation.py.

self = <django.db.backends.sqlite3.base.SQLiteCursorWrapper object at 0x7f9c9513b880>
query = 'SELECT "auth_group"."id", "auth_group"."name", "auth_group"."name_de", "auth_group"."name_en" FROM "auth_group" ORDER BY "auth_group"."id" ASC', params = ()

    def execute(self, query, params=None):
        if params is None:
            return super().execute(query)
        # Extract names if params is a mapping, i.e. "pyformat" style is used.
        param_names = list(params) if isinstance(params, Mapping) else None
        query = self.convert_query(query, param_names=param_names)
>       return super().execute(query, params)
E       django.db.utils.OperationalError: no such column: auth_group.name_de

To resolve this, I added the TEST_NONSERIALIZED_APPS option.

last-partizan commented 4 months ago

That's a good start. Can you please add Django 5 to the test matrix next?

wookkl commented 4 months ago

Will do!