diff options
| author | Simon Charette <charette.s@gmail.com> | 2021-12-15 19:36:08 -0500 |
|---|---|---|
| committer | Mariusz Felisiak <felisiak.mariusz@gmail.com> | 2021-12-17 07:46:58 +0100 |
| commit | 43289707809c814a70f0db38ca4f82f35f43dbfd (patch) | |
| tree | 84fe47804effc97a2fa02c7a71cb8af72f13f8a4 /django/apps | |
| parent | 40165eecc40f9e223702a41a0cb0958515bb1f82 (diff) | |
Fixed #33366 -- Fixed case handling with swappable setting detection in migrations autodetector.
The migration framework uniquely identifies models by case insensitive
labels composed of their app label and model names and so does the app
registry in most of its methods (e.g. AppConfig.get_model) but it
wasn't the case for get_swappable_settings_name() until this change.
This likely slipped under the radar for so long and only regressed in
b9df2b74b98b4d63933e8061d3cfc1f6f39eb747 because prior to the changes
related to the usage of model states instead of rendered models in the
auto-detector the exact value settings value was never going through a
case folding hoop.
Thanks Andrew Chen Wang for the report and Keryn Knight for the
investigation.
Diffstat (limited to 'django/apps')
| -rw-r--r-- | django/apps/registry.py | 5 |
1 files changed, 3 insertions, 2 deletions
diff --git a/django/apps/registry.py b/django/apps/registry.py index 62650ca4bc..268e1a6af7 100644 --- a/django/apps/registry.py +++ b/django/apps/registry.py @@ -286,13 +286,14 @@ class Apps: change after Django has loaded the settings, there is no reason to get the respective settings attribute over and over again. """ + to_string = to_string.lower() for model in self.get_models(include_swapped=True): swapped = model._meta.swapped # Is this model swapped out for the model given by to_string? - if swapped and swapped == to_string: + if swapped and swapped.lower() == to_string: return model._meta.swappable # Is this model swappable and the one given by to_string? - if model._meta.swappable and model._meta.label == to_string: + if model._meta.swappable and model._meta.label_lower == to_string: return model._meta.swappable return None |
