'Discovers panels to register from the current dashboard module.'

def _autodiscover(self):

    if getattr(self, '_autodiscover_complete', False):
        return
    panels_to_discover = []
    panel_groups = []
    if all([isinstance(i, six.string_types) for i in self.panels]):
        self.panels = [self.panels]
    default_created = False
    for panel_set in self.panels:
        if ((not isinstance(panel_set, collections.Iterable)) and issubclass(panel_set, PanelGroup)):
            panel_group = panel_set(self)
        elif (not isinstance(panel_set, PanelGroup)):
            panel_group = PanelGroup(self, panels=panel_set)
        panels_to_discover.extend(panel_group.panels)
        panel_groups.append((panel_group.slug, panel_group))
        if (panel_group.slug == DEFAULT_PANEL_GROUP):
            default_created = True
    if (not default_created):
        default_group = PanelGroup(self)
        panel_groups.insert(0, (default_group.slug, default_group))
    self._panel_groups = collections.OrderedDict(panel_groups)
    package = '.'.join(self.__module__.split('.')[:(-1)])
    mod = import_module(package)
    for panel in panels_to_discover:
        try:
            before_import_registry = copy.copy(self._registry)
            import_module(('.%s.panel' % panel), package)
        except Exception:
            self._registry = before_import_registry
            if module_has_submodule(mod, panel):
                raise
    self._autodiscover_complete = True
