code: def set_settings(instance=None):
      
  
      global settings
  
      settings = None
  
      if instance:
          settings = import_settings(instance)
  
      elif "INSTANCE_FOR_DYNACONF" in os.environ:
          settings = import_settings(os.environ["INSTANCE_FOR_DYNACONF"])
  
      elif "FLASK_APP" in os.environ:  # pragma: no cover
          with suppress(ImportError, click.UsageError):
              from flask.cli import ScriptInfo
  
              flask_app = ScriptInfo().load_app()
              settings = flask_app.config
              click.echo(
                  click.style(
                      "Flask app detected", fg="white", bg="bright_black"
                  )
              )
  
      elif "DJANGO_SETTINGS_MODULE" in os.environ:  # pragma: no cover
          sys.path.insert(0, os.path.abspath(os.getcwd()))
          try:
              # Django extension v2
              from django.conf import settings
  
              settings.DYNACONF.configure()
          except (ImportError, AttributeError):
              # Backwards compatible with old django extension (pre 2.0.0)
              import dynaconf.contrib.django_dynaconf  # noqa
              from django.conf import settings as django_settings
  
              django_settings.configure()
              settings = django_settings
  
          if settings is not None:
              click.echo(
                  click.style(
                      "Django app detected", fg="white", bg="bright_black"
                  )
              )
  
      if settings is None:
          settings = LazySettings()
docs: Pick correct settings instance and set it to a global variable.