Fixed #21718 -- Renamed has_app to is_installed.
Avoided catching ImproperlyConfigured on django.setup().

Fixed #21737. Thanks Florian for the report.

Also removed redundant imports in that file.