Account Options

  1. Sign in
The old Google Groups will be going away soon.
Switch to the new Google Groups.
Google Groups Home
« Groups Home
Can't run django on Apache
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
  17 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
 
John Maines  
View profile  
 More options Mar 4 2009, 2:47 pm
From: John Maines <jmai...@sun-sentinel.com>
Date: Wed, 4 Mar 2009 11:47:01 -0800 (PST)
Local: Wed, Mar 4 2009 2:47 pm
Subject: Can't run django on Apache
Hello:

I've installed Django 1.0 on Ubuntu and am trying to get it to run on
Apache. Apache is installed, working fine, with mod-python also in
place. I'm new at everything Linux.

But when I try to run my app (a test blog), Apache gives an
ImportError message (below) I have come across NUMEROUS references to
this error message, and the solution usually seems to involve changing
the Python Path. But nothing I try seems to work. I've tried using /
user/local for a path, /var/www; the path to my app. Nothing works.
Any suggestions?

MOD_PYTHON ERROR

ProcessId:      9980
Interpreter:    'mysite'

ServerName:     'ubuntu.ubuntu-domain'
DocumentRoot:   '/var/www/'

URI:            '/mysite'
Location:       '/'
Directory:      None
Filename:       '/var/www/mysite'
PathInfo:       ''

Phase:          'PythonHandler'
Handler:        'django.core.handlers.modpython'

Traceback (most recent call last):

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1537, in HandlerDispatch
    default=default_handler, arg=req, silent=hlist.silent)

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1229, in _process_target
    result = _execute_target(config, req, object, arg)

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1128, in _execute_target
    result = object(arg)

  File "/usr/lib/python2.5/site-packages/django/core/handlers/
modpython.py", line 228, in handler
    return ModPythonHandler()(req)

  File "/usr/lib/python2.5/site-packages/django/core/handlers/
modpython.py", line 191, in __call__
    self.load_middleware()

  File "/usr/lib/python2.5/site-packages/django/core/handlers/
base.py", line 31, in load_middleware
    for middleware_path in settings.MIDDLEWARE_CLASSES:

  File "/usr/lib/python2.5/site-packages/django/conf/__init__.py",
line 28, in __getattr__
    self._import_settings()

  File "/usr/lib/python2.5/site-packages/django/conf/__init__.py",
line 59, in _import_settings
    self._target = Settings(settings_module)

  File "/usr/lib/python2.5/site-packages/django/conf/__init__.py",
line 94, in __init__
    raise ImportError, "Could not import settings '%s' (Is it on
sys.path? Does it have syntax errors?): %s" % (self.SETTINGS_MODULE,
e)

ImportError: Could not import settings 'settings' (Is it on sys.path?
Does it have syntax errors?): No module named settings


 
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.
xankya  
View profile  
 More options Mar 4 2009, 4:28 pm
From: xankya <suzan.sha...@gmail.com>
Date: Wed, 4 Mar 2009 13:28:16 -0800 (PST)
Local: Wed, Mar 4 2009 4:28 pm
Subject: Re: Can't run django on Apache
I guess u need to set python path to mysite plus django folders

In httpd.conf:

<Location "/mysite">
    SetHandler python-program
    PythonHandler django.core.handlers.modpython
    SetEnv DJANGO_SETTINGS_MODULE settings
    PythonDebug On
    PythonPath "['path to mysite', 'path to django'] + sys.path"
</Location>


 
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.
Maines, John  
View profile  
 More options Mar 4 2009, 4:31 pm
From: "Maines, John" <JMai...@sun-sentinel.com>
Date: Wed, 4 Mar 2009 15:31:02 -0600
Local: Wed, Mar 4 2009 4:31 pm
Subject: RE: Can't run django on Apache

Thanks. That's one of the about 50 variables I have tried with the path settings ... still no luck.

-- John


 
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.
Danny Brown  
View profile  
 More options Mar 4 2009, 4:38 pm
From: Danny Brown <danb...@gmail.com>
Date: Wed, 4 Mar 2009 15:38:41 -0600
Local: Wed, Mar 4 2009 4:38 pm
Subject: Re: Can't run django on Apache
try above but change /mysite to /mysite/ and settings to mysite/settings


 
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.
xankya  
View profile  
 More options Mar 6 2009, 6:32 pm
From: xankya <suzan.sha...@gmail.com>
Date: Fri, 6 Mar 2009 15:32:57 -0800 (PST)
Local: Fri, Mar 6 2009 6:32 pm
Subject: Re: Can't run django on Apache
One thing I noticed in my windows and sun solaris is that, there is no
trailing slash in python paths. When I added trailing slash, apache
showed error. So you might as well try removing trailing slash in
python paths.

 
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.
jai  
View profile  
 More options Mar 10 2009, 2:38 am
From: jai <jayapa...@gmail.com>
Date: Mon, 9 Mar 2009 23:38:31 -0700 (PDT)
Local: Tues, Mar 10 2009 2:38 am
Subject: Re: Can't run django on Apache
just put this line in (/etc/apache2/sites-enabled/000-default)

        <Location "/mysite/">
                SetHandler python-program
                PythonHandler django.core.handlers.modpython
                SetEnv DJANGO_SETTINGS_MODULE mysite.settings
                PythonInterpreter  mysite
                PythonDebug On
                PythonPath "['path to django','path to mysite'] +
sys.path"
        </Location>

It should work fine.

On Mar 7, 4:32 am, xankya <suzan.sha...@gmail.com> wrote:


 
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.
Discussion subject changed to "Forms: label translation fails" by Jana Įlvarez Muńiz
Jana Įlvarez Muńiz  
View profile  
 More options Mar 10 2009, 8:59 am
From: Jana Įlvarez Muńiz <jana.alva...@fundacionctic.org>
Date: Tue, 10 Mar 2009 13:59:12 +0100
Local: Tues, Mar 10 2009 8:59 am
Subject: Forms: label translation fails
Hello!

I want to use translation in Django forms (and ModelForms), but the only solution I've found is using the 'label' attribute in the form fields
('from django.utils.translation import ugettext as _' is omitted):

forms.py:
class MyForm(ModelForm):
    name = forms.CharField(label=_('Name'))
    description = forms.CharField(label=_("Description"))
    class Meta:
        model  = models.MyModel
        fields = ('name', 'description')

models.py:
class MyModel (models.Model):
    name = models.CharField(max_length=50,verbose_name=_("Name"))
    description = models.CharField(max_length=200,              verbose_name=_("Description"))

In ticket #3600 (http://code.djangoproject.com/ticket/3600) tells us that label only can be translated with 'gettext' during initialization, and this happens to me too.

Can somebody help me? I think must exist a way to translate fields form for a model...

Thanks!


 
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.
Ramiro Morales  
View profile  
 More options Mar 10 2009, 9:15 am
From: Ramiro Morales <cra...@gmail.com>
Date: Tue, 10 Mar 2009 11:15:03 -0200
Local: Tues, Mar 10 2009 9:15 am
Subject: Re: Forms: label translation fails
On Tue, Mar 10, 2009 at 10:59 AM, Jana Įlvarez Muńiz

<jana.alva...@fundacionctic.org> wrote:

> Hello!

> I want to use translation in Django forms (and ModelForms), but the only solution I've found is using the 'label' attribute in the form fields
> ('from django.utils.translation import ugettext as _' is omitted):

You need to use ugettext_lazy() instead of ugettext().

> forms.py:
> class MyForm(ModelForm):
>    name = forms.CharField(label=_('Name'))
>    description = forms.CharField(label=_("Description"))
>    class Meta:
>        model  = models.MyModel
>        fields = ('name', 'description')

> models.py:
> class MyModel (models.Model):
>    name = models.CharField(max_length=50,verbose_name=_("Name"))
>    description = models.CharField(max_length=200,              verbose_name=_("Description"))

--
Ramiro Morales
http://rmorales.net

 
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.
Jana Įlvarez Muńiz  
View profile  
 More options Mar 10 2009, 10:34 am
From: Jana Įlvarez Muńiz <jana.alva...@fundacionctic.org>
Date: Tue, 10 Mar 2009 15:34:48 +0100
Local: Tues, Mar 10 2009 10:34 am
Subject: RE: Forms: label translation fails

> On Tue, Mar 10, 2009 at 10:59 AM, Jana Įlvarez Muńiz
> <jana.alva...@fundacionctic.org> wrote:

> > Hello!

> > I want to use translation in Django forms (and ModelForms), but the only > > solution I've found is using the 'label' attribute in the form fields
> > ('from django.utils.translation import ugettext as _' is omitted):
> You need to use ugettext_lazy() instead of ugettext().

Thanks! But anyone knows if it exists a way to translate without putting each field twice?:

forms.py:
class MyForm(ModelForm):

        # First:
        name = forms.CharField(label=_('Name'))
        description = forms.CharField(label=_("Description"))

        class Meta:
                model = models.MyModel

                # Second:
                fields = ('name', 'description')


 
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.
Discussion subject changed to "Can't run django on Apache" by Rex
Rex  
View profile  
 More options Mar 14 2009, 10:52 pm
From: Rex <rex.eastbou...@gmail.com>
Date: Sat, 14 Mar 2009 19:52:43 -0700 (PDT)
Local: Sat, Mar 14 2009 10:52 pm
Subject: Re: Can't run django on Apache
On Mar 4, 12:47 pm, John Maines <jmai...@sun-sentinel.com> wrote:

I'm having the same issue as the OP. Each time I go to mysite.com/
myapp, Apache seems to look for a file called /var/www/myapp, instead
of launching the Django project I attempt to specify in my <Location>
directive.

I have a project called "mturk". I want to run it on from mysite.com/
myapp. Based on the answers to the OP's questions, it seems like I
should be putting something like this in one of my configuration
files:

<Location "/myapp/">
        SetHandler python-program
        PythonHandler django.core.handlers.modpython
        SetEnv DJANGO_SETTINGS_MODULE mysite.settings
        PythonOption django.root /home/rex/django/mturk
        PythonDebug On
        PythonPath "['/home/rex/django/mturk'] + sys.path"
</Location>

Some sources say this snippet should go in /etc/apache2/httpd.conf,
and some sources say it should go in /etc/apache2/sites-enabled/000-
default. Which should I go with? Also, I read somewhere that I should
change my DocumentRoot to the path to the Django project, but wouldn't
that expose my database and my Python source?

Thanks,

Rex


 
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.
Malcolm Tredinnick  
View profile  
 More options Mar 14 2009, 11:31 pm
From: Malcolm Tredinnick <malc...@pointy-stick.com>
Date: Sun, 15 Mar 2009 14:31:12 +1100
Local: Sat, Mar 14 2009 11:31 pm
Subject: Re: Can't run django on Apache
On Sat, 2009-03-14 at 19:52 -0700, Rex wrote:

[...]

> <Location "/myapp/">
>         SetHandler python-program
>         PythonHandler django.core.handlers.modpython
>         SetEnv DJANGO_SETTINGS_MODULE mysite.settings
>         PythonOption django.root /home/rex/django/mturk

*sigh* Will people please stop *guessing* at what goes into the
django.root option?  Don't use options you don't understand what they're
for and if you work out that a particular option is needed, understand
what it does before filling it in. :-(

The documentation is pretty clear on what it should contain:
http://docs.djangoproject.com/en/dev/howto/deployment/modpython/#basi...

>         PythonDebug On
>         PythonPath "['/home/rex/django/mturk'] + sys.path"
> </Location>

> Some sources say this snippet should go in /etc/apache2/httpd.conf,
> and some sources say it should go in /etc/apache2/sites-enabled/000-
> default. Which should I go with?

It depends on which distribution you're running. On Fedora, for example,
it goes in /etc/httpd/conf.d/ . So you'll need to provide some more
information.

> Also, I read somewhere that I should
> change my DocumentRoot to the path to the Django project, but wouldn't
> that expose my database and my Python source?

The Django documentation for installing with modpython is accurate and
complete, so use that as your reference (then using the Apache manual
and other places to understand the terms in there if you're not sure).
The above advice is not just bad, it's dangerous and stupid. So you're
right to be suspicious. There's simply no reason to do that.

Regards,
Malcolm


 
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.
Discussion subject changed to "FIXED: Can't run django on Apache" by Rex
Rex  
View profile  
 More options Mar 15 2009, 4:54 pm
From: Rex <rex.eastbou...@gmail.com>
Date: Sun, 15 Mar 2009 13:54:25 -0700 (PDT)
Local: Sun, Mar 15 2009 4:54 pm
Subject: FIXED: Can't run django on Apache

On Mar 14, 7:52 pm, Rex <rex.eastbou...@gmail.com> wrote:

It turns out the problem was my PythonPath directive -- whereas I had
it set to contain the project directory, /home/rex/django/mturk, I
needed to set it to the parent directory, /home/rex/django. It works
now.

 
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.
Bro  
View profile  
 More options Mar 17 2009, 12:59 pm
From: Bro <coolpari...@gmail.com>
Date: Tue, 17 Mar 2009 09:59:57 -0700 (PDT)
Local: Tues, Mar 17 2009 12:59 pm
Subject: Re: FIXED: Can't run django on Apache
The result is :

<Location "/myapp/">
         SetHandler python-program
         PythonHandler django.core.handlers.modpython
         SetEnv DJANGO_SETTINGS_MODULE mysite.settings
         PythonOption django.root /home/rex/django/mturk
         PythonDebug On
         PythonPath "['/home/rex/django/'] + sys.path"
</Location>

?


 
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.
Bro  
View profile  
 More options Mar 17 2009, 1:54 pm
From: Bro <coolpari...@gmail.com>
Date: Tue, 17 Mar 2009 10:54:54 -0700 (PDT)
Local: Tues, Mar 17 2009 1:54 pm
Subject: Re: FIXED: Can't run django on Apache
Hi

I've installed Django 1.02 on my dedibox. I'm trying to make .py file
readable and executable.
Apache, Python, Django are installed.
We have many website :
/var/www/mysite1
/var/www/mysite2
/var/www/mysite3

we have :
/var/django/mysite1
/var/django/mysite2

We configure in /etc/apache2/site-available/mysite1 :

----------
<VirtualHost *:80>
        ServerAdmin webmaster@localhost
        ServerName mysite1.com
        ServerAlias mysite1.com www.mysite1.fr mysite1.fr

        DocumentRoot /var/www/mysite1/
        <Directory />
                Options FollowSymLinks
                AllowOverride None
        </Directory>
        <Directory /var/www/mysite/>
                Options Indexes FollowSymLinks MultiViews
                AllowOverride All
                Order allow,deny
                allow from all
        </Directory>

        <Location "/">
            SetHandler python-program
            PythonHandler django.core.handlers.modpython
            SetEnv DJANGO_SETTINGS_MODULE mysite1.settings
            PythonOption django.root /var/django/mysite1
            PythonPath "['/var/django/', '/var/www'] + sys.path"
            PythonDebug On
        </Location>

        ScriptAlias /cgi-bin/ /usr/lib/cgi-bin/
        <Directory "/usr/lib/cgi-bin">
                AllowOverride None
                Options +ExecCGI -MultiViews +SymLinksIfOwnerMatch
                Order allow,deny
                Allow from all
        </Directory>

        ErrorLog /var/log/apache2/error.log

        # Possible values include: debug, info, notice, warn, error,
crit,
        # alert, emerg.
        LogLevel warn

        CustomLog /var/log/apache2/access.log combined

    Alias /doc/ "/usr/share/doc/"
    <Directory "/usr/share/doc/">
        Options Indexes MultiViews FollowSymLinks
        AllowOverride None
        Order deny,allow
        Deny from all
        Allow from 127.0.0.0/255.0.0.0 ::1/128
    </Directory>

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

But when we go in this url : mysite1.com
We get this error

------------
MOD_PYTHON ERROR

ProcessId:      14693
Interpreter:    mysite.com'

ServerName:     'mysite.com'
DocumentRoot:   '/var/www/mysite/'

URI:            '/'
Location:       '/'
Directory:      None
Filename:       '/var/www/mysite/'
PathInfo:       ''

Phase:          'PythonHandler'
Handler:        'django.core.handlers.modpython'

Traceback (most recent call last):

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1537, in HandlerDispatch
    default=default_handler, arg=req, silent=hlist.silent)

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1229, in _process_target
    result = _execute_target(config, req, object, arg)

  File "/usr/lib/python2.5/site-packages/mod_python/importer.py", line
1128, in _execute_target
    result = object(arg)

  File "/var/lib/python-support/python2.5/django/core/handlers/
modpython.py", line 228, in handler
    return ModPythonHandler()(req)

  File "/var/lib/python-support/python2.5/django/core/handlers/
modpython.py", line 191, in __call__
    self.load_middleware()

  File "/var/lib/python-support/python2.5/django/core/handlers/
base.py", line 44, in load_middleware
    raise exceptions.ImproperlyConfigured, 'Middleware module "%s"
does not define a "%s" class' % (mw_module, mw_classname)

ImproperlyConfigured: Middleware module
"django.contrib.flatpages.middleware" does not define a
"FlatpageFallbackMiddlewar" class


 
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.
Karen Tracey  
View profile  
 More options Mar 17 2009, 9:41 pm
From: Karen Tracey <kmtra...@gmail.com>
Date: Tue, 17 Mar 2009 21:41:10 -0400
Local: Tues, Mar 17 2009 9:41 pm
Subject: Re: FIXED: Can't run django on Apache

On Tue, Mar 17, 2009 at 1:54 PM, Bro <coolpari...@gmail.com> wrote:

> [snip]
> File "/var/lib/python-support/python2.5/django/core/handlers/
> base.py", line 44, in load_middleware
>    raise exceptions.ImproperlyConfigured, 'Middleware module "%s"
> does not define a "%s" class' % (mw_module, mw_classname)

> ImproperlyConfigured: Middleware module
> "django.contrib.flatpages.middleware" does not define a
> "FlatpageFallbackMiddlewar" class

You seem to have dropped the e off the end of FlatpageFallbackMiddelware in
your MIDDLEWARE_CLASSES setting that includes that middleware.

Karen


 
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.
Graham Dumpleton  
View profile  
 More options Mar 17 2009, 9:59 pm
From: Graham Dumpleton <Graham.Dumple...@gmail.com>
Date: Tue, 17 Mar 2009 18:59:48 -0700 (PDT)
Local: Tues, Mar 17 2009 9:59 pm
Subject: Re: FIXED: Can't run django on Apache
Either way, their dango.root setting is wrong as they are setting it
to physical file system path. Remove that whole django.root setting as
you do not need it when mounting at root of site.

The sooner people stop using mod_python the better. ;-)

Graham

On Mar 18, 12:41 pm, Karen Tracey <kmtra...@gmail.com> wrote:


 
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.
Bro  
View profile  
 More options Mar 18 2009, 3:33 pm
From: Bro <coolpari...@gmail.com>
Date: Wed, 18 Mar 2009 12:33:16 -0700 (PDT)
Local: Wed, Mar 18 2009 3:33 pm
Subject: Re: FIXED: Can't run django on Apache
What's the best way to do it ? I don't understand the official
tutorial

 
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 »