#24725: "ProgrammingError: relation does not exist" when renaming many-to-many
target model
---------------------------------+------------------------------------
     Reporter:  dbrgn            |                    Owner:  MarkusH
         Type:  Bug              |                   Status:  assigned
    Component:  Migrations       |                  Version:  1.8
     Severity:  Release blocker  |               Resolution:
     Keywords:  migrations       |             Triage Stage:  Accepted
    Has patch:  0                |      Needs documentation:  1
  Needs tests:  1                |  Patch needs improvement:  0
Easy pickings:  0                |                    UI/UX:  0
---------------------------------+------------------------------------
Changes (by MarkusH):

 * status:  new => assigned
 * owner:  nobody => MarkusH
 * needs_tests:  0 => 1
 * needs_docs:  0 => 1


Comment:

 I localized the error to these four lines:
 
https://github.com/django/django/blob/master/django/db/migrations/operations/models.py#L162-L165

 They wrongly filter out `<ManyToManyRel: debug.john>` on the model
 `debug.Spam` (i.e. `__fake__.Spam`):

 {{{#!python
 ipdb> model._meta.get_fields(include_hidden=True)
 (<ManyToOneRel: debug.john_consumed_food>, <ManyToManyRel: debug.john>,
 <django.db.models.fields.AutoField: id>,
 <django.db.models.fields.CharField: description>)

 ipdb> field = model._meta.get_fields(include_hidden=True)[0]
 ipdb> field
 <ManyToOneRel: debug.john_consumed_food>
 ipdb> field.auto_created
 True
 ipdb> field.concrete
 False
 ipdb> field.hidden
 True
 ipdb> field.many_to_many
 False

 ipdb> field = model._meta.get_fields(include_hidden=True)[1]
 ipdb> field
 <ManyToManyRel: debug.john>
 ipdb> field.auto_created
 True
 ipdb> field.concrete
 False
 ipdb> field.hidden
 False
 ipdb> field.many_to_many
 True
 }}}

--
Ticket URL: <https://code.djangoproject.com/ticket/24725#comment:5>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/063.5b74b5d0232621172e06a97457559f72%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to