Unable to load render_to_response module

52 views
Skip to first unread message

Ganesh Kumar

unread,
Nov 11, 2011, 8:49:08 AM11/11/11
to django...@googlegroups.com
Hi ,

I have tried to load render_to_response module. it's through error. I
have tried download and install the module
https://github.com/jgorset/django-shortcuts
installed sucessfully, But not load any one of you help me guys.


dhana013 ~ $ ipython
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
Type "copyright", "credits" or "license" for more information.

IPython 0.10 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

In [1]: from django.shortcuts import render_to_response
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)

/home/dhana013/<ipython console> in <module>()

/usr/lib/pymodules/python2.6/django/shortcuts/__init__.py in <module>()
8 from django.http import HttpResponse, Http404
9 from django.http import HttpResponseRedirect,
HttpResponsePermanentRedirect
---> 10 from django.db.models.manager import Manager
11 from django.db.models.query import QuerySet
12 from django.core import urlresolvers

/usr/lib/pymodules/python2.6/django/db/__init__.py in <module>()
8 __all__ = ('backend', 'connection', 'DatabaseError', 'IntegrityError')
9
---> 10 if not settings.DATABASE_ENGINE:
11 settings.DATABASE_ENGINE = 'dummy'
12

/usr/lib/pymodules/python2.6/django/utils/functional.pyc in
__getattr__(self, name)
267 def __getattr__(self, name):
268 if self._wrapped is None:
--> 269 self._setup()
270 if name == "__members__":
271 # Used to implement dir(obj)

dhana013 ~ $ ipython
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
Type "copyright", "credits" or "license" for more information.

IPython 0.10 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

In [1]: from django.shortcuts import render_to_response
---------------------------------------------------------------------------
ImportError Traceback (most recent call last)

/home/dhana013/<ipython console> in <module>()

/usr/lib/pymodules/python2.6/django/shortcuts/__init__.py in <module>()
8 from django.http import HttpResponse, Http404
9 from django.http import HttpResponseRedirect,
HttpResponsePermanentRedirect
---> 10 from django.db.models.manager import Manager
11 from django.db.models.query import QuerySet
12 from django.core import urlresolvers

/usr/lib/pymodules/python2.6/django/db/__init__.py in <module>()
8 __all__ = ('backend', 'connection', 'DatabaseError', 'IntegrityError')
9
---> 10 if not settings.DATABASE_ENGINE:
11 settings.DATABASE_ENGINE = 'dummy'
12

/usr/lib/pymodules/python2.6/django/utils/functional.pyc in
__getattr__(self, name)
267 def __getattr__(self, name):
268 if self._wrapped is None:
--> 269 self._setup()
270 if name == "__members__":
271 # Used to implement dir(obj)


/usr/lib/pymodules/python2.6/django/conf/__init__.pyc in _setup(self)
36 # NOTE: This is arguably an EnvironmentError, but
that causes

37 # problems with Python's interactive help.

---> 38 raise ImportError("Settings cannot be imported,
because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
39
40 self._wrapped = Settings(settings_module)

ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.

In [2]:

/usr/lib/pymodules/python2.6/django/conf/__init__.pyc in _setup(self)
36 # NOTE: This is arguably an EnvironmentError, but
that causes

37 # problems with Python's interactive help.

---> 38 raise ImportError("Settings cannot be imported,
because environment variable %s is undefined." % ENVIRONMENT_VARIABLE)
39
40 self._wrapped = Settings(settings_module)

ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.

In [2]:

-Ganesh.

Did I learn something today? If not, I wasted it.

Daniel Roseman

unread,
Nov 11, 2011, 10:36:49 AM11/11/11
to django...@googlegroups.com
On Friday, 11 November 2011 13:49:08 UTC, Ganesh-Bugcy wrote:
Hi ,

I have tried to load render_to_response module. it's through error. I
have tried download and install the module
https://github.com/jgorset/django-shortcuts
installed sucessfully, But not load any one of  you help me guys.


dhana013 ~ $ ipython
Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
Type "copyright", "credits" or "license" for more information.

IPython 0.10 -- An enhanced Interactive Python.
?         -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help      -> Python's own help system.
object?   -> Details about 'object'. ?object also works, ?? prints more.

In [1]: from django.shortcuts import render_to_response
---------------------------------------------------------------------------
ImportError                               Traceback (most recent call last)

<snip>

ImportError: Settings cannot be imported, because environment variable
DJANGO_SETTINGS_MODULE is undefined.

In [2]:

-Ganesh.

Did I learn something today? If not, I wasted it.


As has been pointed out to you before, `django.shortcuts.render_to_response` has nothing whatsoever to do with the django-shortcuts third-party package. It does not need to be installed separately.

The traceback which you quote shows you exactly what is wrong - you have not set the DJANGO_SETTINGS_MODULE environment variable. To avoid the need for this, start your shell with `./manage.py shell` rather than ipython directly.
--
DR.

 

Bowen

unread,
Nov 11, 2011, 10:09:55 AM11/11/11
to django...@googlegroups.com
I get the same error about django settings Before, I know how to get it done under IDE ,but for the thing under command line,cannot fix it. Under IDE , I just set the django module Settings to be project name plus settings.
Regards, Bowen

发自我的 iPhone

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

马博文

unread,
Nov 11, 2011, 12:26:24 PM11/11/11
to django...@googlegroups.com
hi, Daniel:
   That does work, you solve a big problem for me. Thanks a lot.
   Also, it seems like manage.py have lots of built in command which are doing different things. Could you give a thread that i can access to learn more about those commands? thanks
By the way, i will tell people who have met the same problem the solution.
Thans again.
regards,
Bowen
> --
> 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/-/ZDIT9_mUqlkJ.

Ganesh Kumar

unread,
Nov 11, 2011, 11:24:00 PM11/11/11
to django...@googlegroups.com
HI

Thanks Daniel it's working me. finally i understand third party
modules did not load bash, If you want load bash, you have set
DJANGO_SETTINGS_MODULE , other wise start with your project directory

$ python manage.py shell


Python 2.6.5 (r265:79063, Apr 16 2010, 13:09:56)
Type "copyright", "credits" or "license" for more information.

IPython 0.10 -- An enhanced Interactive Python.
? -> Introduction and overview of IPython's features.
%quickref -> Quick reference.
help -> Python's own help system.
object? -> Details about 'object'. ?object also works, ?? prints more.

In [1]: from django.shortcuts import render_to_response

In [2]:

thanks guys.

-Ganesh.

Did I learn something today? If not, I wasted it.

Reply all
Reply to author
Forward
0 new messages