etc/toolbox.py
def import_app_module(app_name, module_name):
    """Returns a module from a given app by its name.

    :param str app_name:
    :param str module_name:
    :rtype: module or None

    """
    name_split = app_name.split('.')
    if name_split[-1][0].isupper():  # Seems that we have app config class path here.
        app_name = '.'.join(name_split[:-2])

    module = import_module(app_name)

    try:
        sub_module = import_module('%s.%s' % (app_name, module_name))
        return sub_module

    except:

        # The same bubbling strategy as in autodiscover_modules().
        if module_has_submodule(module, module_name):  # Module is in a package.
            raise

        return None
def import_app_module(app_name, module_name):
    name_split = app_name.split('.')
    if name_split[-1][0].isupper():  # Seems that we have app config class path here.
        app_name = '.'.join(name_split[:-2])

    module = import_module(app_name)

    try:
        sub_module = import_module('%s.%s' % (app_name, module_name))
        return sub_module

    except:

        # The same bubbling strategy as in autodiscover_modules().
        if module_has_submodule(module, module_name):  # Module is in a package.
            raise

        return None
def import_app_module ( app_name , module_name ) : name_split = app_name . split ( '.' ) if name_split [ - 1 ] [ 0 ] . isupper ( ) : # Seems that we have app config class path here. app_name = '.' . join ( name_split [ : - 2 ] ) module = import_module ( app_name ) try : sub_module = import_module ( '%s.%s' % ( app_name , module_name ) ) return sub_module except : # The same bubbling strategy as in autodiscover_modules(). if module_has_submodule ( module , module_name ) : # Module is in a package. raise return None
Returns a module from a given app by its name.

    :param str app_name:
    :param str module_name:
    :rtype: module or None
Returns a module from a given app by its name .