Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
This PR moves the code that customizes
TranslatableModel
subclasses from theTranslatableModelBase
metaclass into a signal handler, connected to Django's builtinclass_prepared
. It gets triggered almost at the same point, but does not conflict with other metaclass-using apps.We are 100% sure it gets registered in time as it is in the same module as
TranslatableModel
.Here is the detailed list of changes:
TranslatableModelBase
and mark it as deprecated. Testcase checks that nothing is broken and a warning is thrown.__new__
method to aprepare_translatable_model
signal handler._base_manager
to never be an instance ofTranslationManager
or a subclass. This was actually missing from the metaclass code (*)contribute_translations
out of the model, next to the signal handler. It has no business inside the model class and polluted its namespace.Tests pass. No behavior change was expected.
(*) it has no influence as
_base_manager
would only get overriden when usinguse_for_related_fields = True
, and this override only breaks if thedefault_class
of the queryset is set toTranslationQueryset
. Still, this is the correct behavior.