Register a SA Forums Account here!
JOINING THE SA FORUMS WILL REMOVE THIS BIG AD, THE ANNOYING UNDERLINED ADS, AND STUPID INTERSTITIAL ADS!!!

You can: log in, read the tech support FAQ, or request your lost password. This dumb message (and those ads) will appear on every screen until you register! Get rid of this crap by registering your own SA Forums Account and joining roughly 150,000 Goons, for the one-time price of $9.95! We charge money because it costs us money per month for bills, and since we don't believe in showing ads to our users, we try to make the money back through forum registrations.
 
  • Post
  • Reply
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...

Adbot
ADBOT LOVES YOU

Senso
Nov 4, 2005

Always working

bitprophet posted:

Senso, if you have a minute, you should definitely do a quick search on the Django bug tracker to see if there's a ticket for this already, and if not, make a quick one with the info you just posted - it sounds like this might be a genuine minor bug in the Postgres support, and if so, it'd be great to have it officially reported so it can be fixed in trunk :)

Good idea. I assumed it was already fixed but I did a search and found a similar problem with MySQL but not with PostgreSQL.
So I've opened Ticket #6987.

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.

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. :wtf:
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? :bang:


EDIT: Huuuh, I moved everything outside my home and put it in /opt, changed all the path definitions and now it works. Djangooooo :argh:

Senso fucked around with this message at 22:11 on Aug 28, 2008

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.

Senso
Nov 4, 2005

Always working
Django 1.0 just came out, should it really be upgraded on a "production" website?

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.

Adbot
ADBOT LOVES YOU

Senso
Nov 4, 2005

Always working
I have a weird problem.
:words:

EDIT: I found my mistake, sorry.

Senso fucked around with this message at 21:38 on Sep 11, 2008

  • 1
  • 2
  • 3
  • 4
  • 5
  • Post
  • Reply