﻿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
24537	Migration autodetector not detecting RenameModel if foreign keys are defined before sibling fields	David Sanders	Markus Holtermann	"(This may be related to #22931 as there was some discussion about failure to detect model renaming there, although that ticket focused more on exceptions being raised.)

Django Migrations seems to generate model migrations with foreign keys placed last in a CreateModel migration, regardless of where they are defined in the model.  This can affect later model renames as the autodetector fails to recognise that the model is the same; the newly generated model state will have the same order as the model.

I've created a test case to confirm that the autodetector won't detect a rename if the foreign keys are in a different order: https://github.com/rapilabs/django/blob/master/tests/migrations/test_autodetector.py#L660"	Bug	closed	Migrations	dev	Normal	fixed	RenameModel		Accepted	1	0	0	0	0	0
