-
-
Notifications
You must be signed in to change notification settings - Fork 3.6k
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
Add Mexican Spanish as a project language #3588
Merged
ericholscher
merged 1 commit into
readthedocs:master
from
benjaoming:feature/add-mexican-spanish
Jun 6, 2018
Merged
Changes from all commits
Commits
File filter
Filter by extension
Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't edit the migration, as it's already been executed in production. A new migration should be created.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Django is currently very simple-minded: If you change ANY property of a field, it will require a migration.
It's okay to edit
choices
from the POV that you don't want a new migration every time that someone added another choice. It has no effect on the DB.However, if you think it's a bad precedence, I can also add a new migration. IMO this doesn't scale with all the language codes that could potentially be added as project languages. You would just get a huge mess of migrations.
Another option would be to redefine the migration to find its choices from
constants
such that it would require no maintenance!There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Yeah, a new migration is the most technically correct, so I think we prefer that.
Though changing choices doesn't result in a database schema change, there will be an inconsistency between the model and the migration representation. Editing an existing migration worries me because of this and I don't know enough about django internals to say that there is no fallout from this.
Importing constants in a migration has the same effect, and is particularly worrisome because the code will evolve, whereas each migration is a point in time snapshot. Relying on code for defaults/etc in migrations results in migrations that aren't necessarily reproducible.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@agjohnson
Using a term like "technically correct" does not quite convince me, because I think you're incorrect about your assumption on migrations being sets of totally static code ;) So there's no real technical correctness to be established.
Why would a list of tuples for
choices
result in something that's unpredictable when it's fetched fromconstants
? Are those notconstants
? I can only see the extra no-op migration boiler code being a cause of much more concern if I wanted to maintain a code base?I've had to update migrations before because of internal changes in Django and apps that shipped field types. Data migrations can also attract hind-sight updates with similar argumentation. Oh and then there's stuff like
verbose_name
where I'd also argue that adding a migration for every change is overkill.The docs about field
choices
:Further:
I would think that both these comments indirectly support making a constant list of tuples play the part of a dynamic variable in the migration.
If you insist, I'll add a migration! But I won't without having warned against it and recommended another approach firstly...
As said before, the motivation for discussing this should be that many more languages are potentially subject to be added. The list from
django.conf.global_settings.LANGUAGES
isn't covered yet.There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
...moreover, this list: https://support.crowdin.com/api/language-codes/ ;)