WebFaction
Community site: login 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 21 Aug '11, 18:10

apechai
112
accept rate: 0%


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.

permanent link

answered 21 Aug '11, 18:24

johns
5.4k312
accept rate: 23%

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.

(21 Aug '11, 19:54) apechai

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

(21 Aug '11, 19:59) johns

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).

(21 Aug '11, 20:33) apechai

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.

(21 Aug '11, 20:47) johns

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.

(22 Aug '11, 13:49) apechai

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?

permanent link

answered 22 Aug '11, 09:44

tclancy
861515
accept rate: 6%

Your answer
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

Markdown Basics

  • *italic* or _italic_
  • **bold** or __bold__
  • link:[text](http://url.com/ "title")
  • image?![alt text](/path/img.jpg "title")
  • numbered list: 1. Foo 2. Bar
  • to add a line break simply add two spaces to where you would like the new line to be.
  • basic HTML tags are also supported

Question tags:

×909
×27
×16
×15
×9

question asked: 21 Aug '11, 18:10

question was seen: 7,901 times

last updated: 22 Aug '11, 13:50

WEBFACTION
REACH US
SUPPORT
AFFILIATE PROGRAM
LEGAL
© COPYRIGHT 2003-2019 SWARMA LIMITED - WEBFACTION IS A SERVICE OF SWARMA LIMITED
REGISTERED IN ENGLAND AND WALES 5729350 - VAT REGISTRATION NUMBER 877397162
5TH FLOOR, THE OLD VINYL FACTORY, HAYES, UB3 1HA, UNITED KINGDOM