<s> def generic_autodiscover ( module_name ) : <EOL> """<STR_LIT>""" <EOL> from django . utils . importlib import import_module <EOL> from django . core . exceptions import ImproperlyConfigured <EOL> import imp <EOL> import sys <EOL> from django . conf import settings <EOL> for app in settings . INSTALLED_APPS : <EOL> try : <EOL> import_module ( app ) <EOL> app_path = sys . modules [ app ] . __path__ <EOL> except AttributeError : <EOL> continue <EOL> try : <EOL> imp . find_module ( module_name , app_path ) <EOL> except ImportError : <EOL> continue <EOL> try : <EOL> import_module ( '<STR_LIT>' % ( app , module_name ) ) <EOL> except ImproperlyConfigured : <EOL> continue <EOL> app_path = sys . modules [ '<STR_LIT>' % ( app , module_name ) ] </s>
