Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Feature: support language-specific field defaults #700

Conversation

sergei-maertens
Copy link
Contributor

@sergei-maertens sergei-maertens commented Aug 30, 2023

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 sergei-maertens force-pushed the feature/698-translated-model-field-default branch from dd6f8f2 to 41d7db6 Compare September 4, 2023 13:48
@sergei-maertens sergei-maertens force-pushed the feature/698-translated-model-field-default branch from 41d7db6 to 5f94bd8 Compare September 4, 2023 13:55
@sergei-maertens
Copy link
Contributor Author

Migration fixes applied here too

@last-partizan
Copy link
Collaborator

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

@sergei-maertens
Copy link
Contributor Author

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

@sergei-maertens sergei-maertens force-pushed the feature/698-translated-model-field-default branch from 89a5c67 to 836daa0 Compare September 5, 2023 07:58
@sergei-maertens
Copy link
Contributor Author

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

@last-partizan
Copy link
Collaborator

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.

@sergei-maertens sergei-maertens force-pushed the feature/698-translated-model-field-default branch from 79891da to 836daa0 Compare September 5, 2023 15:52
@last-partizan
Copy link
Collaborator

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
Copy link
Contributor Author

sergei-maertens commented Sep 7, 2023 via email

@last-partizan last-partizan merged commit 2657de7 into deschler:master Sep 8, 2023
74 checks passed
@Viicos Viicos deleted the feature/698-translated-model-field-default branch May 3, 2024 09:41
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Add a feature to translate the model.fields default value based on field language.
2 participants