[1.7.x] Fixed #23322 -- Use resolved swappable model for dependency resolution during makemigrations

Backport of 144cff3f51 from master