Google Groups Home
Help | Sign in
Django and mod_python issues
There are currently too many topics in this group that display first. To make this topic appear first, remove this option from another topic.
There was an error processing your request. Please try again.
flag
  7 messages - Collapse all  -  Translate all to Translated (View all originals)
The group you are posting to is a Usenet group. Messages posted to this group will make your email address visible to anyone on the Internet.
Your reply message has not been sent.
Your post was successful
 
From:
To:
Cc:
Followup To:
Add Cc | Add Followup-to | Edit Subject
Subject:
Validation:
For verification purposes please type the characters you see in the picture below or the numbers you hear by clicking the accessibility icon. Listen and type the numbers you hear
 
Tipan  
View profile  
 More options Dec 5 2006, 9:15 am
From: "Tipan" <t...@ortengo.co.uk>
Date: Tue, 05 Dec 2006 06:15:50 -0800
Local: Tues, Dec 5 2006 9:15 am
Subject: Django and mod_python issues
I've seen various posts with similar problems, but not managed to find
consistent advice on trouble shooting this issue.

I've got an installation of xampp Apache 2.2 and mod_python 3.2.10 and
Python 2.5. Running on Windows 2003 server.

I have mod_python working fine in apache - I can view the contents of a
simple python file (mptest from mod_python testing).

I installed Django -  I did this from the latest files via Subversion,
because the install file on Official version failed several times (the
note said Python 2.5 may cause problems)

I've added details of my project file in a location statement to
httpd.conf.

However, when I open the project in the browser:
http://localhost:8888/myproject/

I get the following error(s) displayed in the browser:
-----------------------------------------------
Mod_python error: "PythonHandler django.core.handlers.modpython"

Traceback (most recent call last):

  File "D:\Python25\Lib\site-packages\mod_python\apache.py", line 299,
in HandlerDispatch
    result = object(req)

  File
"D:\Python25\lib\site-packages\django\core\handlers\modpython.py", line
177, in handler
    return ModPythonHandler()(req)

  File
"D:\Python25\lib\site-packages\django\core\handlers\modpython.py", line
145, in __call__
    self.load_middleware()

  File "D:\Python25\lib\site-packages\django\core\handlers\base.py",
line 22, in load_middleware
    for middleware_path in settings.MIDDLEWARE_CLASSES:

  File "D:\Python25\lib\site-packages\django\conf\__init__.py", line
27, in __getattr__
    self._import_settings()

  File "D:\Python25\lib\site-packages\django\conf\__init__.py", line
54, in _import_settings
    self._target = Settings(settings_module)

  File "D:\Python25\lib\site-packages\django\conf\__init__.py", line
82, in __init__
    raise EnvironmentError, "Could not import settings '%s' (Is it on
sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE, e)

EnvironmentError: Could not import settings 'myproject.settings' (Is it
on sys.path? Does it have syntax errors?): No module named
myproject.settings
------------------------------------------
My httpd.conf file has the following settings at the end:
--
<Directory "d:/program files/xampp/htdocs/test">
      AllowOverride FIleinfo
      AddHandler mod_python .py
      PythonHandler mptest
      PythonDebug On
</Directory>

<Location "/,yproject/">
    SetHandler python-program
    PythonPath "['d:/program files/xampp/htdocs/myproject'] + sys.path"
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE myproject.settings
    PythonDebug On
</Location>
--
I've checked the "import django" from the python command line and there
were no errors, so I believe it's installed and accessible.

I've tried manually adding to sys.path the directories of the django
installation and my project with no effect. I'm wondering whether by
manually installing the django files from subversion I missed some key
settings, but I've not found any notes to allow me to check.

Can anyone give me any pointers for resolving this behaviour?


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremy Dunck  
View profile  
(1 user)  More options Dec 5 2006, 9:30 am
From: "Jeremy Dunck" <jdu...@gmail.com>
Date: Tue, 5 Dec 2006 08:30:15 -0600
Local: Tues, Dec 5 2006 9:30 am
Subject: Re: Django and mod_python issues
On 12/5/06, Tipan <t...@ortengo.co.uk> wrote:
...

> EnvironmentError: Could not import settings 'myproject.settings' (Is it
> on sys.path? Does it have syntax errors?): No module named
> myproject.settings
...
>     PythonPath "['d:/program files/xampp/htdocs/myproject'] + sys.path"
> Can anyone give me any pointers for resolving this behaviour?

I think you want this:

PythonPath "['d:/program files/xampp/htdocs/'] + sys.path"

(I don't think this has anything to do with Py2.5, etc.  It's just
python path issues.  :)


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Nicolas Steinmetz  
View profile  
(1 user)  More options Dec 5 2006, 9:32 am
From: Nicolas Steinmetz <nsteinm...@gmail.com>
Date: Tue, 05 Dec 2006 15:32:31 +0100
Local: Tues, Dec 5 2006 9:32 am
Subject: Re: Django and mod_python issues
Tipan a écrit :

>     PythonPath "['d:/program files/xampp/htdocs/myproject'] + sys.path"

Try : PythonPath "['d:/program files/xampp/htdocs/'] + sys.path"

Nicolas


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Waylan Limberg  
View profile  
(1 user)  More options Dec 5 2006, 10:17 am
From: "Waylan Limberg" <way...@gmail.com>
Date: Tue, 5 Dec 2006 10:17:22 -0500
Local: Tues, Dec 5 2006 10:17 am
Subject: Re: Django and mod_python issues
On 12/5/06, Nicolas Steinmetz <nsteinm...@gmail.com> wrote:

> Tipan a écrit :

> >     PythonPath "['d:/program files/xampp/htdocs/myproject'] + sys.path"

> Try : PythonPath "['d:/program files/xampp/htdocs/'] + sys.path"

Actually, you may want to include both lines. That way,
`myproject.settings` will still work and you will be able to `import
myapp` instead of `import myproject.myapp` making your apps more
portable across projects.

--
----
Waylan Limberg
way...@gmail.com


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Tipan  
View profile  
 More options Dec 5 2006, 11:31 am
From: "Tipan" <t...@ortengo.co.uk>
Date: Tue, 05 Dec 2006 08:31:25 -0800
Local: Tues, Dec 5 2006 11:31 am
Subject: Re: Django and mod_python issues
Thanks for the advice. Adding the line:

    PythonPath "['d:/program files/xampp/htdocs'] + sys.path"

to my httpd.conf overcame the issue with loading myproject module.
Simple when you know how.

Thanks again, Tim


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
brandon  
View profile  
 More options Dec 8 2006, 4:02 pm
From: "brandon" <mirc...@gmail.com>
Date: Fri, 08 Dec 2006 21:02:10 -0000
Local: Fri, Dec 8 2006 4:02 pm
Subject: Re: Django and mod_python issues
Hi I'm using the same setup. However I'm pretty new to python and
django.

I have C:\Program Files\xampp\htdocs as my default directory

Where should I place django?

I placed it in C:\Program Files\xampp\htdocs\python\

but can't get the 'import django' working properly... sadly i have to
use windows.

Thanks for the help.

B

On Dec 5, 10:31 am, "Tipan" <t...@ortengo.co.uk> wrote:


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
Jeremy Dunck  
View profile  
 More options Dec 8 2006, 4:30 pm
From: "Jeremy Dunck" <jdu...@gmail.com>
Date: Fri, 8 Dec 2006 15:30:55 -0600
Local: Fri, Dec 8 2006 4:30 pm
Subject: Re: Django and mod_python issues
On 12/8/06, brandon <mirc...@gmail.com> wrote:

> Hi I'm using the same setup. However I'm pretty new to python and
> django.

Which django version/revision are you using?

> I have C:\Program Files\xampp\htdocs as my default directory

> Where should I place django?

Somewhere on the python path.  :)

The usual approach is to either place it in site-packages or to place
a .pth file in site-packages, and then point the .pth to where ever
Django is.

Let's go the .pth route.

In the python terminal, do this:

import sys
print sys.path

That'll result in a list of directories, one of which is
"site-packages", probably something like this:

C:\python25\lib\site-packages\

In that directory, create a simple text file named <something>.pth
file.  django.pth probably is sensible.

In the .pth file, place the path to wherever Django exists on your
filesystem.  As an example, if you downloaded Django-0.95.tar.gz and
unzipped it into C:\Django-0.95\, then you'll want to put that in your
.pth

When python starts up, it starts with a simple sys.path, then adds
paths in the PYTHONPATH variable, plus any directories listed in .pth
files found on those paths.

When you code:
import django
what happens is, python looks for a package (that is, a .py file) or a
module (that is, a directory which contains an __init__.py file) named
"django" in any of the directories listed in sys.path, in order.

By adding django.pth to your site-packages directory (which is
included in the base sys.path list), you add C:\Django-0.95 (or
whatever dir you listed) to the sys.path list.

Then, when you run "import django", it finds the module "django"
within that dir.

The Python tutorial is surprisingly weak in this area, but if you
haven't read that, it's a good place to get started with Python.
http://docs.python.org/tut/tut.html

If you already know how to program, you'll also want to look at
http://diveintopython.org

Cheers,
  Jeremy


    Reply to author    Forward  
You must Sign in before you can post messages.
To post a message you must first join this group.
Please update your nickname on the subscription settings page before posting.
You do not have the permission required to post.
End of messages
« Back to Discussions « Newer topic     Older topic »

Create a group - Google Groups - Google Home - Terms of Service - Privacy Policy
©2009 Google