Wednesday, May 16, 2012

Re: settings file being imported four times

Yes, when I put a print statement in my settings file, it prints out twice everytime I start the server. The file has to be imported in multiple places, and so it gets executed multiple times. I'm not sure what your error is, but it doesn't seem to be related to the multiple imports.

On Wednesday, May 16, 2012 7:10:14 PM UTC-4, Tomas Neme wrote:
is it normal that the settings file is being imported four times? I'd give more info, but I really have no clue what's going on

here's my manage.py:

from django.core.management import execute_manager
import imp
try:
    imp.find_module('local_settings') # Assumed to be in the same directory.
except ImportError:
    import sys
    sys.stderr.write("""Error: Can't find the file 'local_settings.py' in the directory containing %r.
It appears you've customized things.
You'll have to run django-admin.py, passing it your settings module.
(If the file local_settings.py does indeed exist, it's causing an ImportError somehow.)
""" % __file__)
    sys.exit(1)

import local_settings

if __name__ == '__main__':
    execute_manager(local_settings)


And I printed a stacktrace at the top of my local_settings file. It does a 'from settings import *' at the top.

lacrymology@Roller:boilerplate$ ./manage.py runserver
local_settings
 File "./manage.py", line 15, in <module>
   import local_settings
 File "/home/lacrymology/workspace/django/groupsolo/boilerplate/boilerplate/local_settings.py", line 4, in <module>
   traceback.print_stack()
###############################################
local_settings
 File "./manage.py", line 18, in <module>
   execute_manager(local_settings)
 File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
   utility.execute()
 File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
   self.fetch_command(subcommand).run_from_argv(self.argv)
 File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 252, in fetch_command
   app_name = get_commands()[subcommand]
 File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 101, in get_commands
   apps = settings.INSTALLED_APPS
 File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/utils/functional.py", line 276, in __getattr__
   self._setup()
 File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
   self._wrapped = Settings(settings_module)
 File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 87, in __init__
   mod = importlib.import_module(self.SETTINGS_MODULE)
 File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
   __import__(name)
 File "/home/lacrymology/workspace/django/groupsolo/boilerplate/boilerplate/../boilerplate/local_settings.py", line 4, in <module>
   traceback.print_stack()
###############################################
No handlers could be found for logger "keyedcache"
local_settings
 File "./manage.py", line 15, in <module>
   import local_settings
 File "/home/lacrymology/workspace/django/groupsolo/boilerplate/boilerplate/local_settings.py", line 4, in <module>
   traceback.print_stack()
###############################################
local_settings
 File "./manage.py", line 18, in <module>
   execute_manager(local_settings)
 File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 438, in execute_manager
   utility.execute()
 File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 379, in execute
   self.fetch_command(subcommand).run_from_argv(self.argv)
 File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 252, in fetch_command
   app_name = get_commands()[subcommand]
 File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/core/management/__init__.py", line 101, in get_commands
   apps = settings.INSTALLED_APPS
 File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/utils/functional.py", line 276, in __getattr__
   self._setup()
 File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
   self._wrapped = Settings(settings_module)
 File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/conf/__init__.py", line 87, in __init__
   mod = importlib.import_module(self.SETTINGS_MODULE)
 File "/home/lacrymology/workspace/django/groupsolo/boilerplate/env/local/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
   __import__(name)
 File "/home/lacrymology/workspace/django/groupsolo/boilerplate/boilerplate/../boilerplate/local_settings.py", line 4, in <module>
   traceback.print_stack()
###############################################
No handlers could be found for logger "keyedcache"
Validating models...

modeltranslation: Registered 1 models for translation (Entry).
0 errors found
Django version 1.3.1, using settings 'boilerplate.local_settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.

--
"The whole of Japan is pure invention. There is no such country, there are no such people" --Oscar Wilde

|_|0|_|
|_|_|0|
|0|0|0|

(\__/)
(='.'=)This is Bunny. Copy and paste bunny 
(")_(") to help him gain world domination.

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/zdsHdviyBg0J.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to django-users+unsubscribe@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate