#35424: Migration autodetector fails when order_with_respect_to is removed, but 
an
_order field remains
--------------------------------------+------------------------
               Reporter:  stuarta0    |          Owner:  nobody
                   Type:  Bug         |         Status:  new
              Component:  Migrations  |        Version:  4.2
               Severity:  Normal      |       Keywords:
           Triage Stage:  Unreviewed  |      Has patch:  0
    Needs documentation:  0           |    Needs tests:  0
Patch needs improvement:  0           |  Easy pickings:  1
                  UI/UX:  0           |
--------------------------------------+------------------------
 We have a project with a large number of migrations that began failing
 during migrate/makemigrations due to order_with_respect_to having been
 removed, and an explicit _order field added. The historic migration
 contains this operation:

 {{{
 migrations.AlterOrderWithRespectTo(
     name='choice',
     order_with_respect_to=None,
 ),
 }}}

 This causes an issue with the code introduced in commit
 
https://github.com/django/django/commit/aa4acc164d1247c0de515c959f7b09648b57dc42
 which was subsequently "fixed" in
 https://code.djangoproject.com/ticket/33449 but remains failing in the
 case described above.

 A minimal reproducible case has been created here:
 https://github.com/stuarta0/django-order-with-respect-to based on the
 django docs polls app.

 A possible solution may be to fall back to field_name if
 order_with_respect_to is either missing, or present with None (which is
 what occurs above):

 {{{
 def get_field(self, field_name):
     if field_name == "_order":
         field_name = self.options.get("order_with_respect_to") or
 field_name
     return self.fields[field_name]
 }}}
-- 
Ticket URL: <https://code.djangoproject.com/ticket/35424>
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/0107018f3d1648cb-d7615771-8955-4d42-aaa0-5444c7b76de3-000000%40eu-central-1.amazonses.com.

Reply via email to