1
0
mirror of https://github.com/django/django.git synced 2025-10-31 09:41:08 +00:00

Fixed #31742 -- Fixed makemigrations crash on ForeignKey to an app with mixed case label.

Regression in 9e1b6b8a66.

Thanks Ignacio Santolin for the report.
This commit is contained in:
Mariusz Felisiak
2020-06-26 23:18:59 +02:00
committed by GitHub
parent 09914ccf68
commit 62d85a2835
2 changed files with 33 additions and 1 deletions

View File

@@ -582,7 +582,11 @@ class ForeignObject(RelatedField):
if self.remote_field.parent_link:
kwargs['parent_link'] = self.remote_field.parent_link
if isinstance(self.remote_field.model, str):
kwargs['to'] = self.remote_field.model.lower()
if '.' in self.remote_field.model:
app_label, model_name = self.remote_field.model.split('.')
kwargs['to'] = '%s.%s' % (app_label, model_name.lower())
else:
kwargs['to'] = self.remote_field.model.lower()
else:
kwargs['to'] = self.remote_field.model._meta.label_lower
# If swappable is True, then see if we're actually pointing to the target