An ImproperlyConfigured exception will be raised they mismatch. Backport of 1c58cabad7 and a2cd0e12c9 from master