#31742: makemigrations crashes for ForeignKey with mixed-case app name.
----------------------------------+------------------------------------
     Reporter:  Ignacio Santolin  |                    Owner:  nobody
         Type:  Bug               |                   Status:  new
    Component:  Migrations        |                  Version:  3.1
     Severity:  Release blocker   |               Resolution:
     Keywords:                    |             Triage Stage:  Accepted
    Has patch:  0                 |      Needs documentation:  0
  Needs tests:  0                 |  Patch needs improvement:  0
Easy pickings:  0                 |                    UI/UX:  0
----------------------------------+------------------------------------

Comment (by felixxm):

 Potential fix:
 {{{
 diff --git a/django/db/models/fields/related.py
 b/django/db/models/fields/related.py
 index d517d7269b..894d931d50 100644
 --- a/django/db/models/fields/related.py
 +++ b/django/db/models/fields/related.py
 @@ -582,7 +582,8 @@ 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()
 +            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._meta.label_lower
          # If swappable is True, then see if we're actually pointing to
 the target
 }}}

-- 
Ticket URL: <https://code.djangoproject.com/ticket/31742#comment:2>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.7eec5467b16efbfab9cfabb259f2bab7%40djangoproject.com.

Reply via email to