django setting problem on windows

1 view
Skip to first unread message

online

unread,
May 3, 2009, 1:24:37 AM5/3/09
to Django users
I have mod_python set working fine with apache.

I have django setting as following at apache
--------------------------------------------------------------------------------------------
<VirtualHost *:80>
ServerAdmin webm...@dummy-host2.li
DocumentRoot "C:/depot/projects/web/"
ServerName web
ServerAlias *.web
ErrorLog "logs/dummy-host2.li-error_log"
CustomLog "logs/dummy-host2.li-access_log" common


<Location "C:/depot/projects/web/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
SetEnv DJANGO_SETTINGS_MODULE web.settings
PythonOption django.root "C:/depot/projects/web/"
PythonDebug On
</Location>

<Location "/media">
SetHandler None
</Location>

<LocationMatch "\.(jpg|gif|png|css|js)$">
SetHandler None
</LocationMatch>

</VirtualHost>
---------------------------------------------------------------------------------------------

But I always got error

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

Thanks for any help!



Malcolm Tredinnick

unread,
May 3, 2009, 1:33:31 AM5/3/09
to django...@googlegroups.com
On Sat, 2009-05-02 at 22:24 -0700, online wrote:
> I have mod_python set working fine with apache.
>
> I have django setting as following at apache
> --------------------------------------------------------------------------------------------
> <VirtualHost *:80>
> ServerAdmin webm...@dummy-host2.li
> DocumentRoot "C:/depot/projects/web/"
> ServerName web
> ServerAlias *.web
> ErrorLog "logs/dummy-host2.li-error_log"
> CustomLog "logs/dummy-host2.li-access_log" common
>
>
> <Location "C:/depot/projects/web/">

I'm surprised you get the error you do, because this line should pretty
much be a showstopper for having anything inside it ever being used by
an incoming request. Go back to the documentation for Apache again. You
haven't given the Location directive a URL. You've given it a directory
path.

I would also suspect you're going to need to set the PythonPath option,
based on the file paths you've mentioned here, since they won't be on
the default Python path.

Regards,
Malcolm


Croydon

unread,
May 3, 2009, 2:35:07 AM5/3/09
to Django users
I just installed Djang/XAMPP on windows using this guide
http://jyotirmaya.blogspot.com/2008/11/xampp-python-django.html

zayatzz

unread,
May 4, 2009, 10:49:38 AM5/4/09
to Django users
Posting because i just set up httpd.conf on linux computer few days
ago and it took me a while to get it working as i wanted to.

If i just compare the way how i set it up and how you did it Then the
difference is that you have no pythonpath like Malcolm said and
location should be either "/web/" or "/"

Take a look at 2nd example here :http://docs.djangoproject.com/en/dev/
howto/deployment/modpython/

Thats the one i used to get it working.

Alan

On May 3, 8:24 am, online <online.service....@gmail.com> wrote:
> I have mod_python set working fine with apache.
>
> I have django setting as following at apache
> --------------------------------------------------------------------------------------------
> <VirtualHost *:80>
>     ServerAdmin webmas...@dummy-host2.li

online

unread,
May 8, 2009, 1:16:44 AM5/8/09
to Django users
Thanks, i tried changing

<Location "C:/depot/projects/web/">
to
<Location "/web/"> or <Location "/>


still no luck

zayatzz

unread,
May 8, 2009, 1:31:24 AM5/8/09
to Django users
If you look at the example i pointed at on django page, then then you
notice that it says path/to/project in pythonpath.

your pythonpath is : PythonPath "['C:/depot/projects/web/'] +
sys.path"

Which seems to me is like path/with/project and should be /depot/
projects as far as i can tell.

If you fix that then change django root to /web/ and leave location to
"/web/"

Check the example on djagopage too, just in case. im writing this by
heart and i am known by simple mistakes that i make :)'

Alan

On May 8, 8:16 am, online <online.service....@gmail.com> wrote:
> Thanks, i tried changing
y>

Phil Mocek

unread,
May 8, 2009, 1:45:39 AM5/8/09
to django...@googlegroups.com
On Thu, May 07, 2009 at 10:16:44PM -0700, online wrote:
> Thanks, i tried changing
>
> <Location "C:/depot/projects/web/">
> to
> <Location "/web/"> or <Location "/>

Your third attempt is not even valid syntax. Doesn't it seem a
little strange that in the other cases you had quotes enclosing a
string but then in the third, you did not?

Your problem is completely unrelated to with Django, so it's a bit
out of place on this list. As Malcom said previously, you need to
go read about Apache configuration. It seems that you either
didn't read or misunderstood what you read. Given that you
haven't asked any questions in an attempt to fill in the parts you
don't understand, it seems likely that you didn't even read any
relevant Apache docs.

Maybe if you cite the page that you're using as a reference in
your attempts to use Apache's location directive, and also explain
your present understanding of it, someone can help guide you to
whatever part you're missing or misunderstanding.

--
Phil Mocek

online

unread,
May 8, 2009, 9:46:39 PM5/8/09
to Django users
Thanks all!

Finally, i got django working with apache 2.2 mod_python3.1

settings:

<Location "/">
SetHandler python-program
PythonHandler django.core.handlers.modpython
PythonOption django.root /web
SetEnv DJANGO_SETTINGS_MODULE web.settings
PythonPath "['C:/depot/projects'] + sys.path"
PythonDebug On
</Location>

Thanks again.



On May 7, 10:45 pm, Phil Mocek <pmocek-list-django-us...@mocek.org>
wrote:
Reply all
Reply to author
Forward
0 new messages