﻿id	summary	reporter	owner	description	type	status	component	version	severity	resolution	keywords	cc	stage	has_patch	needs_docs	needs_tests	needs_better_patch	easy	ui_ux
35424	Migration autodetector fails when order_with_respect_to is removed, but an _order field remains	Stuart Attenborrow	Daniel Patrick	"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]
}}}
"	Bug	closed	Migrations	4.2	Normal	fixed			Ready for checkin	1	0	0	0	0	0
