deschler / django-modeltranslation

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

Feature: support language-specific field defaults #700

Closed sergei-maertens closed 10 months ago

sergei-maertens commented 10 months ago

Closes #698, overlaps with #699 w/r to re-generated initial migrations

When django-modeltranslation creates the translation fields (foo_en, foo_de...) and the base field has a callable default set, any language-aware content is now translated with the field's language.

The mechanism is rather simple - Field.get_default is overridden to temporarily activate field.language.

sergei-maertens commented 10 months ago

Migration fixes applied here too

last-partizan commented 10 months ago

Merged migration fixes, now please rebase this branch or merge master into it to resolve conflicts.

sergei-maertens commented 10 months ago

Sure, I'll be in the office in 30 mins and you can expect the rebase then

sergei-maertens commented 10 months ago

@last-partizan I've rebased and rewritten the commit messages to use conventional commit

last-partizan commented 10 months ago

Looks fine, but gitlab-ci is failing for the reasons unrelated to this PR. I'll try running it again later today.

If that doesn't work, i'll test it locally and merge tomorrow.

last-partizan commented 10 months ago

Is there anything else you want to check or fix before merging?

It looks fine to me, and i plan merge it tomorrow.

sergei-maertens commented 10 months ago

No, let's go for it!

On Thu, 7 Sep 2023, 14:51 Serhii Tereshchenko, @.***> wrote:

Is there anything else you want to check or fix before merging?

It looks fine to me, and i plan merge it tomorrow.

— Reply to this email directly, view it on GitHub https://github.com/deschler/django-modeltranslation/pull/700#issuecomment-1710098111, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABKDJVU3YH44LKC2FR6ZANTXZG7NNANCNFSM6AAAAAA4EOS4UE . You are receiving this because you authored the thread.Message ID: @.***>