#26564: Migration for renaming M2M field intermediate model causes exception
--------------------------------+--------------------------------------
     Reporter:  MJafarMashhadi  |                    Owner:  nobody
         Type:  Bug             |                   Status:  new
    Component:  Migrations      |                  Version:  1.9
     Severity:  Normal          |               Resolution:
     Keywords:                  |             Triage Stage:  Unreviewed
    Has patch:  0               |      Needs documentation:  0
  Needs tests:  0               |  Patch needs improvement:  0
Easy pickings:  0               |                    UI/UX:  0
--------------------------------+--------------------------------------

Comment (by MJafarMashhadi):

 I checked  {{{ type(old_field.remote_field.through) }}} and it is a
 string.
 That's because in models i used class name as a string not pointer to
 class name. I mean i defined through filed like this:
 {{{ services = models.ManyToManyField('Service',
 through='ServiceActivation') }}}
 not like this:
 {{{ services = models.ManyToManyField('Service',
 through=ServiceActivation) }}}

 The code checks {{{ _meta }}} on {{{ old_field.remote_field.through }}}
 field, since it's still a string and is not resolved to corresponding
 class it raises exception above ({{{ AttributeError: 'str' object has no
 attribute '_meta' }}}).

 Since this is a no-op migration i can just remove the migration without
 breaking my website as a workaround, But i think this definitely is a bug
 in migrations not something that just happened to me.

--
Ticket URL: <https://code.djangoproject.com/ticket/26564#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 django-updates+unsubscr...@googlegroups.com.
To post to this group, send email to django-updates@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/072.13dfaacd5f0857b825e45a4e6307ec54%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to