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?
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
[mailto:django-users@googlegroups.com]On Behalf Of xankya
Sent: Wednesday, March 04, 2009 4:28 PM
To: Django users
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>
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.
> 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.
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...
> 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"))
> 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"))
> 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?
[snip]
> ImportError: Could not import settings 'settings' (Is it on sys.path?
> Does it have syntax errors?): No module named settings
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:
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?
*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. :-(
> 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.
> On Mar 4, 12:47 pm, John Maines <jmai...@sun-sentinel.com> wrote:
> > Hello:
> > I've installed Django 1.0 on Ubuntu and am trying to get it to run on
> >Apache.Apacheis 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),Apachegives 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?
> [snip]
> > ImportError: Could not import settings 'settings' (Is it on sys.path?
> > Does it have syntax errors?): No module named settings
> I'm having the same issue as the OP. Each time I go to mysite.com/
> myapp,Apacheseems 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:
> 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
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.
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 :
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
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
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: