Re: I encountered a core exception and need help configuring for a database. My OS is Ubuntu 12.10 32 bit

1,548 views
Skip to first unread message

Lightning

unread,
Mar 21, 2013, 1:13:00 PM3/21/13
to django...@googlegroups.com


On Wednesday, March 20, 2013 11:50:49 PM UTC-7, Lightning wrote:

enter image description hereI need help configuring for a database. Is there a paper I can read that will give me an overview on this procedure? I encountered a core exception. My OS is Ubuntu 12.10 32 bit.

ENVIRONMENT_VARIABLE = "DJANGO_SETTINGS_MODULE"
class LazySettings(LazyObject):
    """
    A lazy proxy for either global Django settings or a custom settings object.
    The user can manually configure settings prior to using them. Otherwise,
    Django uses the settings module pointed to by DJANGO_SETTINGS_MODULE.
    """



 ImproperlyConfigured: Requested setting USE_I18N, but settings are not configured. You must either define the environment variable DJANGO_SETTINGS_MODULE or call settings.configure() before accessing settings.

Bill Freeman

unread,
Mar 21, 2013, 4:39:34 PM3/21/13
to django...@googlegroups.com
Setting an environment variable is done by saying something like:

lightning@rigel5:~$ export DJANGO_SETTINGS_MODULE='mysite.settings'

assuming that your settings.py file is in a directory named "mysite", in turn in the current directory (your home directory, if I interpret your prompt string correctly).  Then that command may work.

But that's the painful way to do that.  Presumably there is a file named manage.py either in the same directory as settings.py (older Djangos) or one directory up (newer Djangos).  'cd' to the directory containing manage.py and type:

lightning@rigel5:pathToDirectoryContainingManage_py$ python manage.py diffsettings

If you look at manage.py with 'less' or with an editor, you will see that it sets the DJANGO_SETTINGS_MODULE environment variable (though using python code, rather than shell code) appropriately (for use from the current directory) before doing other stuff.

For my money, django-admin.py should only ever be used for its startproject command.  Everything else should be done with manage.py after cd'ing to the directory that contains it (or from a wsgi script, which also sets the DJANGO_SETTINGS_MODULE environment variable and adjusts sys.path to be sure that the directory containing manage.py is there, but that will come much later for you, I think).

Bill

--
You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-users...@googlegroups.com.
To post to this group, send email to django...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users?hl=en.
For more options, visit https://groups.google.com/groups/opt_out.
 
 

hugh Manchu

unread,
Mar 22, 2013, 1:47:30 AM3/22/13
to django...@googlegroups.com
ightning@rigel5:~$ cd /home/lightning/Documents/django-works/mysite/
lightning@rigel5:~/Documents/django-works/mysite$ pathToDirectoryContainingManage_py$ python manage.py diffsettings
pathToDirectoryContainingManage_py$: command not found
lightning@rigel5:~/Documents/django-works/mysite$ pathToDirectoryContainingManage_py
pathToDirectoryContainingManage_py: command not found
lightning@rigel5:~/Documents/django-works/mysite$ ightning@rigel5:pathToDirectoryContainingManage_py$ python manage.py diffsettings
ightning@rigel5:pathToDirectoryContainingManage_py$: command not found
lightning@rigel5:~/Documents/django-works/mysite$ cd /manage.py
bash: cd: /manage.py: No such file or directory
lightning@rigel5:~/Documents/django-works/mysite$ export DJANGO_SETTINGS_MODULE='mysite.settings'
lightning@rigel5:~/Documents/django-works/mysite$ django-admin.py test
Traceback (most recent call last):
  File "/usr/local/bin/django-admin.py", line 5, in <module>
    management.execute_from_command_line()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 453, in execute_from_command_line
    utility.execute()
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 392, in execute
    self.fetch_command(subcommand).run_from_argv(self.argv)
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 263, in fetch_command
    app_name = get_commands()[subcommand]
  File "/usr/local/lib/python2.7/dist-packages/django/core/management/__init__.py", line 109, in get_commands
    apps = settings.INSTALLED_APPS
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 52, in __getattr__
    self._setup(name)
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 47, in _setup
    self._wrapped = Settings(settings_module)
  File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 132, in __init__
    raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
ImportError: Could not import settings 'mysite.settings' (Is it on sys.path?): No module named mysite.settings
lightning@rigel5:~/Documents/django-works/mysite$ 



--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/h7BncMwxH7E/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.

hugh Manchu

unread,
Mar 22, 2013, 1:51:39 AM3/22/13
to django...@googlegroups.com
I gave it a shot Bill an thanks for the reply btw ... this also id not work I pasted what i did in the terminal. settings.py is nested in /home/lightning/Docments/django-works/mysite/manage.py. settings.py is one down


On Thu, Mar 21, 2013 at 1:39 PM, Bill Freeman <ke1...@gmail.com> wrote:

--
You received this message because you are subscribed to a topic in the Google Groups "Django users" group.
To unsubscribe from this topic, visit https://groups.google.com/d/topic/django-users/h7BncMwxH7E/unsubscribe?hl=en.
To unsubscribe from this group and all its topics, send an email to django-users...@googlegroups.com.

hugh Manchu

unread,
Mar 22, 2013, 1:54:58 AM3/22/13
to django...@googlegroups.com
CORRECTION;

I gave it a shot Bill an thanks for the reply btw ... this also id not work I pasted what i did in the terminal. manage.py NOT settings.py is nested in /home/lightning/Docments/django-works/mysite/manage.py. settings.py is one down

Iftikhar Ali

unread,
Apr 25, 2013, 10:01:30 AM4/25/13
to django...@googlegroups.com
 buddy i am also getting the same error... if you have so far got the answer please help me too...

C. Kirby

unread,
Apr 25, 2013, 10:11:00 AM4/25/13
to django...@googlegroups.com
Can you show the file structure of you project like this:

/project
-app1/
--models.py
--views.py
-manage.py
-settings.py

with your actual files and structure?
Also it would be useful to see the contents of you manage.py file

hugh Manchu

unread,
May 1, 2013, 11:05:26 AM5/1/13
to django...@googlegroups.com
make sure you have your settings.py configured properly... if you still need help I will check back later today and see what i can do.


On Thu, Apr 25, 2013 at 7:01 AM, Iftikhar Ali <iftikh...@gmail.com> wrote:
 buddy i am also getting the same error... if you have so far got the answer please help me too...

--
Reply all
Reply to author
Forward
0 new messages