On 23/10/2012 2:10pm, Mike Dewhirst wrote:
On 23/10/2012 8:37am, DjgoNy wrote:
I have problem importing from  django_tables import tables
and when i do it on manage.py shell i get this error.

 >>> import django_tables2
Traceback (most recent call last):
   File "<stdin>", line 1, in <module>
   File "build\bdist.win32\egg\django_tables2\__init__.py", line 3, in
<module>
   File "build\bdist.win32\egg\django_tables2\tables.py", line 4, in
<module>
   File "c:\Python27\lib\site-packages\django\db\__init__.py", line 11,
in <module>
     if DEFAULT_DB_ALIAS not in settings.DATABASES:
   File "c:\Python27\lib\site-packages\django\utils\functional.py", line
184, in inner
     self._setup()
   File "c:\Python27\lib\site-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.
 >>>

how do i fix it.
what am i missing here....

You are directly importing a package which is on the Python path so the
system finds it ok. But, that package (django_tables2) apparently
expects to be imported by some other bit of code which already knows
where your settings.py file lives.

If you want to import it directly it needs to know where to look.

You might need a PYTHONPATH environment variable which specifies the
path to your Django project. If settings.py lives in
C:\webwork\djngony\project\xyz\settings.py. Then your PYTHONPATH needs
to include C:\webwork\djngony

The traceback indicates, you need a DJANGO_SETTINGS_MODULE environment
variable. In my example above it would simply be project.xyz

Correction ... project.xyz.settings

or xyz.settings if C:\webwork\djngony\project is in the PYTHONPATH



hth

Mike

thank you so much.

--
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/-/e3UHoYJI0KsJ.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at
http://groups.google.com/group/django-users?hl=en.



--

Climate Pty Ltd
PO Box 308
Mount Eliza
Vic 3930
Australia +61

T: 03 9787 6598
M: 0411 704 143


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

Reply via email to