- Senso
- Nov 4, 2005
-
Always working
|
I've installed everything on Windows as I'll be testing it on XP before moving to a Linux server.
I've installed Apache2, Postgresql 8.3.1, etc. Then I got this error:
code:C:\django\blog>python manage.py syncdb
Traceback (most recent call last):
File "manage.py", line 11, in <module>
execute_manager(settings)
File "C:\Python25\Lib\site-packages\django\core\management.py", line 1672, in execute_manager
execute_from_command_line(action_mapping, argv)
File "C:\Python25\Lib\site-packages\django\core\management.py", line 1571, in execute_from_command_line
action_mapping[action](int(options.verbosity), options.interactive)
File "C:\Python25\Lib\site-packages\django\core\management.py", line 504, in syncdb
cursor = connection.cursor()
File "C:\Python25\Lib\site-packages\django\db\backends\postgresql_psycopg2\base.py", line 57, in cursor
postgres_version = [int(val) for val in cursor.fetchone()[0].split()[1].split('.')]
ValueError: invalid literal for int() with base 10: '1,'
So I went in \Lib\site-packages\django\db\backends\postgresql_psycopg2\base.py and printed the value that caused the error to see what was the problem. It turns out that doing
code:SELECT version()
('PostgreSQL 8.3.1, compiled by Visual C++ build 1400',)
There is a comma after the version number. So I made a simple change to postgresql_psycopg2\base.py:
code:postgres_version = [int(val) for val in cursor.fetchone()[0].split()[1].split('.')]
TO
postgres_version = [int(val[b].strip(',')[/b]) for val in cursor.fetchone()[0].split()[1].split('.')]
And I was able to run syncdb without problem. I got that problem after following the Windows setup tutorial in the OP so just in case someone else gets the same issue...
|
#
¿
Apr 8, 2008 15:52
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
May 6, 2024 20:17
|
|
- Senso
- Nov 4, 2005
-
Always working
|
I've tried so many editors but, on Windows, Notepad++ is the one I prefer. It's quick, has dozens of specific plugins, good syntax highlighting and code folding, tabs and more.
|
#
¿
Apr 9, 2008 02:48
|
|
- Senso
- Nov 4, 2005
-
Always working
|
Ok, I'm going crazy here. I've setup Django correctly, my small test project loads and works fine with the built-in Django server. My problem is with Apache - it just won't work.
I get this error in Apache:
code:MOD_PYTHON ERROR
ProcessId: 27457
DocumentRoot: '/var/www/'
URI: '/'
Location: '/'
Directory: None
Filename: '/var/www/'
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 177, in handler
return ModPythonHandler()(req)
File "/usr/lib/python2.5/site-packages/django/core/handlers/modpython.py", line 145, in __call__
self.load_middleware()
File "/usr/lib/python2.5/site-packages/django/core/handlers/base.py", line 22, 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 55, in _import_settings
self._target = Settings(settings_module)
File "/usr/lib/python2.5/site-packages/django/conf/__init__.py", line 83, 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 'project.settings'
(Is it on sys.path? Does it have syntax errors?): No module named project.settings
So it's not finding project.settings.
code:mlan:~/proj$ python
Python 2.5.1 (r251:54863, Jul 31 2008, 23:17:40)
[GCC 4.1.3 20070929 (prerelease) (Ubuntu 4.1.2-16ubuntu2)] on linux2
Type "help", "copyright", "credits" or "license" for more information.
>>> import project.settings
>>>
It's RIGHT THERE in my PythonPath!
Here's my relevant Apache config:
code:<virtualhost *>
ServerAdmin [email]hurr@durr.com[/email]
DocumentRoot /var/www/
<Location />
PythonHandler django.core.handlers.modpython
PythonPath "['/home/mlan/proj'] + sys.path"
SetEnv DJANGO_SETTINGS_MODULE project.settings
SetHandler python-program
PythonDebug On
</Location>
ErrorLog /var/log/apache2/error.log
LogLevel warn
CustomLog /var/log/apache2/access.log combined
ServerSignature On
</virtualhost>
The permissions are correct, www-data has rx rights on the whole project tree. I don't know now... It works perfectly well with "python manage.py runserver".
Even the env variable is set correctly...
code:mlan@:/home/mlan# echo $PYTHONPATH
/home/mlan/proj
I have Apache 2.2.4 on Ubuntu. Has anybody run into that before?
EDIT: Huuuh, I moved everything outside my home and put it in /opt, changed all the path definitions and now it works. Djangooooo
Senso fucked around with this message at 22:11 on Aug 28, 2008
|
#
¿
Aug 28, 2008 21:24
|
|
- Senso
- Nov 4, 2005
-
Always working
|
bitprophet posted:
Your PythonPath and shell environment != Apache's PythonPath and shell environment. Two totally different things.
I know that but as you can see, I didn't take chances. PythonPath is defined in the VirtualHost Apache definition but I also defined it in bash, just to make sure.
bitprophet posted:
That said, since you were adding the project directory (and, I assume /home/mlan/proj/project was your Django project root, and not /home/mlan/proj, otherwise that would be another problem) to Apache's PythonPath in your conf, I think NSW is correct, it was probably permissions.
Right, in the code I pasted, /home/mlan/proj was the Django root. /home/mlan/proj/myproject was the actual project. I read about that and I knew that I shouldn't give it the path of a single project.
It probably was permissions after all. But the thing is, the django folders in /opt and in /home/mlan have the same permissions... And I'm a loving Linux sysadmin, I'm ashamed! Oh well, it works now.
|
#
¿
Aug 29, 2008 04:01
|
|
- Senso
- Nov 4, 2005
-
Always working
|
Django 1.0 just came out, should it really be upgraded on a "production" website?
|
#
¿
Sep 5, 2008 11:50
|
|
- Senso
- Nov 4, 2005
-
Always working
|
MEAT TREAT posted:
My question has more to do with the hosting of this project. I'm expecting it to generate a lot of traffic and wanted to know if those shared hosting plans would be enough. At what point will 64 MB not be enough to serve all my users? I don't have a lot of money right now, so I wanted to see how long that shared hosting would last me.
I can't provide hard data but I host a wiki for a popular game and I get about ~50,000 pageviews per day. I go through about 80GB/month. The whole deal (the hosting is a goon company so I think I had a small deal) costs me nearly $20/month.
|
#
¿
Sep 8, 2008 12:54
|
|
- Adbot
-
ADBOT LOVES YOU
|
|
#
¿
May 6, 2024 20:17
|
|