Backport of 0ed7d155635da9f79d4dd67e4889087d3673c6da from master
Thanks kostko for the report.
We want to be able to use it for instance for discovering `tasks.py` modules inside the INSTALLED_APPS. This commit therefore moves the logic to `autodiscover_modules` method in django.utils.module_loading.