parameters: (fn)
return_statement: return setup
docstring: Decorator that will initialize Django in the context of
      the application from which `opal x` is run.
  
      Note that this is not used to _switch_ settings, but to
      initialize them for the first time and allow us to e.g.
      import models, run django management commands etc
docstring_summary: Decorator that will initialize Django in the context of
      the application from which `opal x` is run.
docstring_tokens: Decorator that will initialize Django in the context of the application from which opal x is run .
function: def setup_django(fn):
      """
      Decorator that will initialize Django in the context of
      the application from which `opal x` is run.
  
      Note that this is not used to _switch_ settings, but to
      initialize them for the first time and allow us to e.g.
      import models, run django management commands etc
      """
  
      @functools.wraps(fn)
      def setup(*a, **k):
          if 'DJANGO_SETTINGS_MODULE' not in os.environ:
              module = '{0}.settings'.format(find_application_name())
              os.environ['DJANGO_SETTINGS_MODULE'] = module
  
          if '.' not in sys.path:
              sys.path.append('.')
  
          import django
          django.setup()
          return fn(*a, **k)
  
      return setup
function_tokens: def setup_django ( fn ) : @ functools . wraps ( fn ) def setup ( * a , * * k ) : if 'DJANGO_SETTINGS_MODULE' not in os . environ : module = '{0}.settings' . format ( find_application_name ( ) ) os . environ [ 'DJANGO_SETTINGS_MODULE' ] = module if '.' not in sys . path : sys . path . append ( '.' ) import django django . setup ( ) return fn ( * a , * * k ) return setup