[1.7.x] Fixed #23341 -- Better stacktrace error for makemigrations

Refs https://code.djangoproject.com/ticket/23341 and PR https://github.com/django/django/pull/3100