login community faq

Hi, I am having problems with syncdb and settings - checked the forum and docs but still haven't been able to figure it out.

I was able to set up a django app using the tutorial while using startproject / startapp on the server. I am also able to syncdb with a mysql database set up. So setting up the app and syncdb on the server is not a problem.

However, I am having problems when I am trying to syncdb on an application which I uploaded from github (and works on my development machine).

After setting up a Django 1.3 / Python 2.6 app ('django3rd'), I uploaded the application ('bookmark') into the django3rd dir: [apechai@web212 django3rd]$ git clone git@github.com:Apechai/bookmarks.git

then edited the wsgi to have 'bookmarks.settings' and renamed myproject.wsgi to bookmarks.wsgi: [apechai@web212 django3rd]$ vi myproject.wsgi

import os import sys

from django.core.handlers.wsgi import WSGIHandler

os.environ['DJANGO_SETTINGS_MODULE'] = 'bookmarks.settings' application = WSGIHandler()

then edited http conf to point to bookmarks.wsgi: [apechai@web212 conf]$ vi httpd.conf

changed the myproject.wsgi to: WSGIScriptAlias / /home/apechai/webapps/django3rd/bookmarks.wsgi

then edited settings.py in /django3rd/bookmarks/ to switch from sqlite3 to mysql.

When I run syncdb, I get an Import error. (I already set the default Python to 2.6 in .bash_profile):

[apechai@web212 bookmarks]$ python manage.py syncdb Traceback (most recent call last): File "manage.py", line 14, in <module> execute_manager(settings) File "/home/apechai/webapps/django3rd/lib/python2.6/django/core/management/init.py", line 438, in execute_manager utility.execute() File "/home/apechai/webapps/django3rd/lib/python2.6/django/core/management/init.py", line 379, in execute self.fetch_command(subcommand).run_from_argv(self.argv) File "/home/apechai/webapps/django3rd/lib/python2.6/django/core/management/init.py", line 261, in fetch_command klass = load_command_class(app_name, subcommand) File "/home/apechai/webapps/django3rd/lib/python2.6/django/core/management/init.py", line 67, in load_command_class module = import_module('%s.management.commands.%s' % (app_name, name)) File "/home/apechai/webapps/django3rd/lib/python2.6/django/utils/importlib.py", line 35, in import_module import(name) File "/home/apechai/webapps/django3rd/lib/python2.6/django/core/management/commands/syncdb.py", line 7, in <module> from django.core.management.sql import custom_sql_for_model, emit_post_sync_signal File "/home/apechai/webapps/django3rd/lib/python2.6/django/core/management/sql.py", line 6, in <module> from django.db import models File "/home/apechai/webapps/django3rd/lib/python2.6/django/db/init.py", line 14, in <module> if not settings.DATABASES: File "/home/apechai/webapps/django3rd/lib/python2.6/django/utils/functional.py", line 276, in getattr self._setup() File "/home/apechai/webapps/django3rd/lib/python2.6/django/conf/init.py", line 42, in _setup self._wrapped = Settings(settings_module) File "/home/apechai/webapps/django3rd/lib/python2.6/django/conf/init.py", line 89, in init raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e)) ImportError: Could not import settings 'bookmarks.settings' (Is it on sys.path?): No module named settings

Any ideas how to fix this?

asked Aug 21 '11 at 18:10

apechai's gravatar image

apechai
12


If you can't syncdb, it's not an issue with Apache at all, it's an issue with an import. Are there any dependencies in the application you're using? Have they all been installed on the live server?

answered Aug 22 '11 at 09:44

tclancy's gravatar image

tclancy
547

This is a common issue, the problem is apache's config, not wsgi's.

Edit ~/apache2/conf/httpd.conf

The line WSGIPythonPath, it will have 1 or 2 paths, but it will be missing your newly added app path, add it.

answered Aug 21 '11 at 18:24

johns's gravatar image

johns ♦♦
340427

I currently have this set to the app path:

WSGIPythonPath /home/apechai/webapps/django3rd:/home/apechai/webapps/django3rd/lib/python2.6:/home/apechai/webapps/django3rd/bookmarks

I restarted the apache server just in case, but I'm still getting the same error.

(Aug 21 '11 at 19:54) apechai apechai's gravatar image

Try using 'python2.6' to run the command and not just 'python'. the default python version system-wide is 2.4.

(Aug 21 '11 at 19:59) johns ♦♦ johns's gravatar image

Already tried python2.6 manage.py syncdb. (I also already set .bash_profile to alias python2.6. I still get the same error.

I'm not getting the error when I build the app on the server. Is there a reason settings wouldn't be recognized with an uploaded app? I'm going through the same steps on the uploaded app as I did for the built on server app (which works fine).

(Aug 21 '11 at 20:33) apechai apechai's gravatar image

Please submit a support ticket so we can see it live. It is almost 99% of the time a path problem, and sometimes it is something small, but its hard to say without taking a look directly.

(Aug 21 '11 at 20:47) johns ♦♦ johns's gravatar image

Filed a ticket and it was fixed quickly. Turned out my django application name and the application within it couldn't have the same name. Thanks for the help.

(Aug 22 '11 at 13:49) apechai apechai's gravatar image
Your answer
If you have an answer to the above question, then use the form below. Otherwise, use the appropriate 'add new comment' button above to post your feedback.
toggle preview

Follow this question

By Email:

Once you sign in you will be able to subscribe for any updates here

By RSS:

Answers

Answers and Comments

Tags:

×641
×19
×11
×10
×6

Asked: Aug 21 '11 at 18:10

Seen: 2,003 times

Last updated: Aug 22 '11 at 13:50

Plans & prices    Sign up    Why WebFaction?    Contact us    Affiliate program    Support    Legal    Jobs    Blog    Control panel login
Powered by OSQA
© Copyright 2003-2012 Swarma Limited - WebFaction is a service of Swarma Limited