This is a version 1.4 Django.  Yes?

Try adding to manage.py, between the "if ..." line and the "os.environ..."
lines, and indented like the "os.environ..." line:

    import pdb;pdb.set_trace()

Then run:

   $ ./manage.py shell

When it stops at the breakpoint, type:

  p os.environ['DJANGO_SETTINGS_MODULE']

I expect this to complain that there is no such key.  Now type:

  n

to single step over the setdefault line and again type:

  p os.environ['DJANGO_SETTINGS_MODULE']

This time it should be happy and print something like:

  "firstdjango.settings"

Now try typeing (be sure to include the "!"):

  !import firstdjango.settings as s

and if that doesn't raise an error, try:

  pp s.INSTALLED_APPS

If this stuff isn't working do:

  p os.getcwd()
  pp sys.path

Assuming that the current working directory is the one containing manage.py
and the like named directory that in turn contains settings.py, then either
it must be on sys.path, or an empty string (more likely) will be on
sys.path (implying the use of the current working directory).

If everything so far was good, and nobody has a better suggestion, and you
want to take the time, then you can use the "m" command again to step over
the "from ... import ..." line, and then the "s" command to step into the
"execute_from_command_line" function, use "n" to step through it's parts
until you find the one that fails, exit, restart, step back to the failing
part and step into it, repeat until enlightened.

Bill


On Wed, Feb 13, 2013 at 9:20 AM, Yussi <uc.dev.n...@gmail.com> wrote:

> I see what you're doing, (It did take me half an hour of staring at your
> email though)
>
> The steps are:
> $django-admin startproject myproj
> $cd myproj
> $vi myproj/settings.py
> than add your databases
> than run
> $./manage.py syncdb
> not django-admin syncdb
>
>
> On 13/02/13 13:54, Bill Freeman wrote:
>
>> How are you invoking manage.py?  Try cd'ing to the directory containing
>> it before running it and see if that helps.  (That directory will then
>> automatically be on python's sys.path, which is needed.
>> DJANGO_SETTINGS_MODULE must be a python style package.module style path,
>> not a filesystem path, so depending on what yout mean by "path to
>> project" I wouldn't expect your second approach to work either.)
>>
>> On Wed, Feb 13, 2013 at 1:57 AM, kulbhushan patariya
>> <kulbhushan4...@gmail.com 
>> <mailto:kulbhushan4you@gmail.**com<kulbhushan4...@gmail.com>>>
>> wrote:
>>
>>     Hi,
>>     I have following problem regarding Django.
>>     Can anyone help me out
>>     ------------------------------**__----------------------------**
>> --__-----------------
>>     kbjp@kbjp-VGN-CS35GN-B:~/__**Desktop/kbproject/firstjango$
>>
>>     django-admin.py syncdb
>>     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 443, in execute_from_command_line
>>          utility.execute()
>>        File
>>     "/usr/local/lib/python2.7/__**dist-packages/django/core/__**
>> management/__init__.py",
>>     line 382, 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 261, in fetch_command
>>          klass = load_command_class(app_name, subcommand)
>>        File
>>     "/usr/local/lib/python2.7/__**dist-packages/django/core/__**
>> management/__init__.py",
>>     line 69, in load_command_class
>>          module = import_module('%s.management._**_commands.%s' %
>>     (app_name, name))
>>        File
>>     "/usr/local/lib/python2.7/__**dist-packages/django/utils/__**
>> importlib.py",
>>
>>     line 35, in import_module
>>          __import__(name)
>>        File
>>     "/usr/local/lib/python2.7/__**dist-packages/django/core/__**
>> management/commands/syncdb.py"**__,
>>
>>     line 8, in <module>
>>          from django.core.management.sql import custom_sql_for_model,
>>     emit_post_sync_signal
>>        File
>>     "/usr/local/lib/python2.7/__**dist-packages/django/core/__**
>> management/sql.py",
>>
>>     line 6, in <module>
>>          from django.db import models
>>        File
>>     "/usr/local/lib/python2.7/__**dist-packages/django/db/____**
>> init__.py",
>>
>>     line 11, in <module>
>>          if DEFAULT_DB_ALIAS not in settings.DATABASES:
>>        File
>>     "/usr/local/lib/python2.7/__**dist-packages/django/utils/__**
>> functional.py",
>>
>>     line 184, in inner
>>          self._setup()
>>        File
>>     "/usr/local/lib/python2.7/__**dist-packages/django/conf/____**init__.py",
>> line
>>
>>     40, in _setup
>>          raise ImportError("Settings cannot be imported, because
>>     environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
>>     ImportError: Settings cannot be imported, because environment
>>     variable DJANGO_SETTINGS_MODULE is undefined.
>>
>>
>>
>>     Here is the content of manage.py file
>>     ------------------------------**------------------------------**
>> ------------------------------**--------------------------
>>     *#!/usr/bin/env python*
>>     *import os*
>>     *import sys*
>>     *
>>     *
>>     *if __name__ == "__main__":*
>>     *    os.environ.setdefault("DJANGO_**SETTINGS_MODULE",
>>     "firstjango.settings")*
>>     *
>>     *
>>     *    from django.core.management import execute_from_command_line*
>>     *
>>     *
>>     *    execute_from_command_line(sys.**argv)*
>>
>>
>>     ------------------------------**------------------------------**
>> ------------------------------**------------------------------**
>> -----------
>>
>>     Here is the error which i received after executing export
>>     DJANGO_SETTINGS_MODULE=__"path to project"
>>
>>
>>     ------------------------------**__----------------------------**
>> --__--------
>>     kbjp@kbjp-VGN-CS35GN-B:~/__**Desktop/kbproject/firstjango$ export
>>     DJANGO_SETTINGS_MODULE=__**firstjango.settings
>>     kbjp@kbjp-VGN-CS35GN-B:~/__**Desktop/kbproject/firstjango$
>>
>>     django-admin.py syncdb
>>     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 443, in execute_from_command_line
>>          utility.execute()
>>        File
>>     "/usr/local/lib/python2.7/__**dist-packages/django/core/__**
>> management/__init__.py",
>>     line 382, 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 261, in fetch_command
>>          klass = load_command_class(app_name, subcommand)
>>        File
>>     "/usr/local/lib/python2.7/__**dist-packages/django/core/__**
>> management/__init__.py",
>>     line 69, in load_command_class
>>          module = import_module('%s.management._**_commands.%s' %
>>     (app_name, name))
>>        File
>>     "/usr/local/lib/python2.7/__**dist-packages/django/utils/__**
>> importlib.py",
>>
>>     line 35, in import_module
>>          __import__(name)
>>        File
>>     "/usr/local/lib/python2.7/__**dist-packages/django/core/__**
>> management/commands/syncdb.py"**__,
>>
>>     line 8, in <module>
>>          from django.core.management.sql import custom_sql_for_model,
>>     emit_post_sync_signal
>>        File
>>     "/usr/local/lib/python2.7/__**dist-packages/django/core/__**
>> management/sql.py",
>>
>>     line 6, in <module>
>>          from django.db import models
>>        File
>>     "/usr/local/lib/python2.7/__**dist-packages/django/db/____**
>> init__.py",
>>
>>     line 11, in <module>
>>          if DEFAULT_DB_ALIAS not in settings.DATABASES:
>>        File
>>     "/usr/local/lib/python2.7/__**dist-packages/django/utils/__**
>> functional.py",
>>
>>     line 184, in inner
>>          self._setup()
>>        File
>>     "/usr/local/lib/python2.7/__**dist-packages/django/conf/____**init__.py",
>> line
>>
>>     42, in _setup
>>          self._wrapped = Settings(settings_module)
>>        File
>>     "/usr/local/lib/python2.7/__**dist-packages/django/conf/____**init__.py",
>> line
>>
>>     95, in __init__
>>          raise ImportError("Could not import settings '%s' (Is it on
>>     sys.path?): %s" % (self.SETTINGS_MODULE, e))
>>     ImportError: Could not import settings 'firstjango.settings' (Is it
>>     on sys.path?): No module named firstjango.settings
>>     kbjp@kbjp-VGN-CS35GN-B:~/__**Desktop/kbproject/firstjango$
>>
>>
>>     --
>>     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+unsubscribe@**googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
>>     
>> <mailto:django-users%**2bunsubscr...@googlegroups.com<django-users%252bunsubscr...@googlegroups.com>
>> **>.
>>
>>     To post to this group, send email to django-users@googlegroups.com
>>     <mailto:django-users@**googlegroups.com<django-users@googlegroups.com>
>> >.
>>
>>     Visit this group at http://groups.google.com/**
>> group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
>> .
>>     For more options, visit 
>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>> .
>>
>>
>>
>> --
>> 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+unsubscribe@**googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
>> .
>> To post to this group, send email to django-users@googlegroups.com.
>> Visit this group at 
>> http://groups.google.com/**group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
>> .
>> For more options, visit 
>> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
>> .
>>
>>
>>
> --
> 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+unsubscribe@**googlegroups.com<django-users%2bunsubscr...@googlegroups.com>
> .
> To post to this group, send email to django-users@googlegroups.com.
> Visit this group at 
> http://groups.google.com/**group/django-users?hl=en<http://groups.google.com/group/django-users?hl=en>
> .
> For more options, visit 
> https://groups.google.com/**groups/opt_out<https://groups.google.com/groups/opt_out>
> .
>
>
>

-- 
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+unsubscr...@googlegroups.com.
To post to this group, send email to django-users@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.


Reply via email to