Ask Your Question
0

ImportError: Could not import settings 'en.settings'

asked 2012-05-29 05:21:21 -0500

Pepe gravatar image Pepe
71 6 10

I'm trying to deploy askbot on my webserver, but my host provider is telling me that I get this error:

ImportError: Could not import settings 'en.settings' (Is it on
sys.path?): No module named askbot

I'll show you my settings.py and my httpd.conf. Please tell me if you see something wrong:

settings.py:

## Django settings for ASKBOT enabled project.
import os.path
import logging
import sys
import askbot
import site

#this line is added so that we can import pre-packaged askbot dependencies
ASKBOT_ROOT = os.path.abspath(os.path.dirname(askbot.__file__))
site.addsitedir(os.path.join(ASKBOT_ROOT, 'deps'))

DEBUG = True#set to True to enable debugging
TEMPLATE_DEBUG = False#keep false when debugging jinja2 templates
INTERNAL_IPS = ('localhost',)

ADMINS = (
    ('*****', '****@****.***'),
)

MANAGERS = ADMINS

DATABASE_ENGINE = 'mysql' # only postgres (>8.3) and mysql are supported so far others have not been tested yet
DATABASE_NAME = '*****'             # Or path to database file if using sqlite3.
DATABASE_USER = '*****'             # Not used with sqlite3.
DATABASE_PASSWORD = '******'         # Not used with sqlite3.
DATABASE_HOST = ''             # Set to empty string for localhost. Not used with sqlite3.
DATABASE_PORT = ''             # Set to empty string for default. Not used with sqlite3.

#outgoing mail server settings
SERVER_EMAIL = ''
DEFAULT_FROM_EMAIL = ''
EMAIL_HOST_USER = ''
EMAIL_HOST_PASSWORD = ''
EMAIL_SUBJECT_PREFIX = ''
EMAIL_HOST=''
EMAIL_PORT=''
EMAIL_USE_TLS=False
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'

#incoming mail settings
#after filling out these settings - please
#go to the site's live settings and enable the feature
#"Email settings" -> "allow asking by email"
#
#   WARNING: command post_emailed_questions DELETES all 
#            emails from the mailbox each time
#            do not use your personal mail box here!!!
#
IMAP_HOST = ''
IMAP_HOST_USER = ''
IMAP_HOST_PASSWORD = ''
IMAP_PORT = ''
IMAP_USE_TLS = False

# Local time zone for this installation. Choices can be found here:
# http://en.wikipedia.org/wiki/List_of_tz_zones_by_name
# although not all choices may be available on all operating systems.
# On Unix systems, a value of None will cause Django to use the same
# timezone as the operating system.
# If running in a Windows environment this must be set to the same as your
# system time zone.
TIME_ZONE = 'America/Chicago'

SITE_ID = 1

# If you set this to False, Django will make some optimizations so as not
# to load the internationalization machinery.
USE_I18N = True
LANGUAGE_CODE = 'en'

# Absolute path to the directory that holds uploaded media
# Example: "/home/media/media.lawrence.com/"
MEDIA_ROOT = os.path.join(os.path.dirname(__file__), 'askbot', 'upfiles')
MEDIA_URL = '/home/whatzzco/domains/whatzz.com/public_html/en/askbot/upfiles/'
STATIC_URL = '/home/whatzzco/domains/whatzz.com/public_html/en/static/'#this must be different from MEDIA_URL

PROJECT_ROOT = os.path.dirname(__file__)
STATIC_ROOT = os.path.join(PROJECT_ROOT, 'static')

# URL prefix for admin media -- CSS, JavaScript and images. Make sure to use a
# trailing slash.
# Examples: "http://foo.com/media/", "/media/".
ADMIN_MEDIA_PREFIX = STATIC_URL + 'admin/'

# Make up some unique string, and don't share it with anybody.
SECRET_KEY = '**************************************' 

# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
    'django.template.loaders.filesystem.load_template_source',
    'django.template.loaders.app_directories.load_template_source',
    #below is askbot stuff for this tuple
    'askbot.skins.loaders.filesystem_load_template_source',
    #'django.template.loaders.eggs.load_template_source',
)


MIDDLEWARE_CLASSES = (
    #'django.middleware.gzip.GZipMiddleware',
    'django.contrib.sessions.middleware.SessionMiddleware',
    #'django.middleware.cache.UpdateCacheMiddleware',
    'django.middleware.common.CommonMiddleware',
    #'django.middleware.cache.FetchFromCacheMiddleware',
    'django.contrib.auth.middleware.AuthenticationMiddleware',
    #'django.middleware.sqlprint.SqlPrintingMiddleware',

    #below is askbot stuff for this tuple
    'askbot.middleware.anon_user.ConnectToSessionMessagesMiddleware',
    'askbot.middleware.forum_mode.ForumModeMiddleware',
    'askbot.middleware.cancel.CancelActionMiddleware',
    'django.middleware.transaction.TransactionMiddleware',
    #'debug_toolbar.middleware.DebugToolbarMiddleware',
    'askbot.middleware.view_log.ViewLogMiddleware',
    'askbot.middleware.spaceless.SpacelessMiddleware',
)


ROOT_URLCONF = os.path.basename(os.path.dirname(__file__)) + '.urls'


#UPLOAD SETTINGS
FILE_UPLOAD_TEMP_DIR = os.path.join(
                                os.path.dirname(__file__), 
                                'tmp'
                            ).replace('\\','/')

FILE_UPLOAD_HANDLERS = (
    'django.core.files.uploadhandler.MemoryFileUploadHandler',
    'django.core.files.uploadhandler.TemporaryFileUploadHandler',
)
ASKBOT_ALLOWED_UPLOAD_FILE_TYPES = ('.jpg', '.jpeg', '.gif', '.bmp', '.png', '.tiff')
ASKBOT_MAX_UPLOAD_FILE_SIZE = 1024 * 1024 #result in bytes
DEFAULT_FILE_STORAGE = 'django.core.files.storage.FileSystemStorage'


#TEMPLATE_DIRS = (,) #template have no effect in askbot, use the variable below
#ASKBOT_EXTRA_SKINS_DIR = #path to your private skin collection
#take a look here http://askbot.org/en/question/207/

TEMPLATE_CONTEXT_PROCESSORS = (
    'django.core.context_processors.request',
    'askbot.context.application_settings',
    #'django.core.context_processors.i18n',
    'askbot.user_messages.context_processors.user_messages',#must be before auth
    'django.core.context_processors.auth', #this is required for admin
    'django.core.context_processors.csrf', #necessary for csrf protection
)


INSTALLED_APPS = (
    'django.contrib.auth',
    'django.contrib.contenttypes',
    'django.contrib.sessions',
    'django.contrib.sites',
    'django.contrib.staticfiles',

    #all of these are needed for the askbot
    'django.contrib.admin',
    'django.contrib.humanize',
    'django.contrib.sitemaps',
    #'debug_toolbar',
    'askbot',
    'askbot.deps.django_authopenid',
    #'askbot.importers.stackexchange', #se loader
    'south',
    'askbot.deps.livesettings',
    'keyedcache',
    'robots',
    'django_countries',
    'djcelery',
    'djkombu',
    'followit',
    #'avatar',#experimental use git clone git://github.com/ericflo/django-avatar.git$
)


#setup memcached for production use!
#see http://docs.djangoproject.com/en/1.1/topics/cache/ for details
CACHE_BACKEND = 'locmem://'
#needed for django-keyedcache
CACHE_TIMEOUT = 6000
CACHE_PREFIX = 'askbot' #make this unique
CACHE_MIDDLEWARE_ANONYMOUS_ONLY = True
#If you use memcache you may want to uncomment the following line to enable memcached based sessions
#SESSION_ENGINE = 'django.contrib.sessions.backends.cached_db'

AUTHENTICATION_BACKENDS = (
    'django.contrib.auth.backends.ModelBackend',
    'askbot.deps.django_authopenid.backends.AuthBackend',
)

#logging settings
LOG_FILENAME = 'askbot.log'
logging.basicConfig(
    filename=os.path.join(os.path.dirname(__file__), 'log', LOG_FILENAME),
    level=logging.CRITICAL,
    format='%(pathname)s TIME: %(asctime)s MSG: %(filename)s:%(funcName)s:%(lineno)d %(message)s',
)

###########################
#
#   this will allow running your forum with url like http://site.com/forum
#
#   ASKBOT_URL = 'forum/'
#
ASKBOT_URL = 'en/' #no leading slash, default = '' empty string
ASKBOT_TRANSLATE_URL = True #translate specific URLs
_ = lambda v:v #fake translation function for the login url
LOGIN_URL = '/%s%s%s' % (ASKBOT_URL,_('account/'),_('signin/'))
LOGIN_REDIRECT_URL = ASKBOT_URL #adjust, if needed
#note - it is important that upload dir url is NOT translated!!!
#also, this url must not have the leading slash
ALLOW_UNICODE_SLUGS = False
ASKBOT_USE_STACKEXCHANGE_URLS = False #mimic url scheme of stackexchange

#Celery Settings
BROKER_TRANSPORT = "djkombu.transport.DatabaseTransport"
CELERY_ALWAYS_EAGER = True

import djcelery
djcelery.setup_loader()
DOMAIN_NAME = 'whatzz.com'

CSRF_COOKIE_NAME = 'whatzz.com_csrf'
#https://docs.djangoproject.com/en/1.3/ref/contrib/csrf/
#CSRF_COOKIE_DOMAIN = DOMAIN_NAME

STATIC_ROOT = os.path.join(PROJECT_ROOT, "static")
STATICFILES_DIRS = (os.path.join(ASKBOT_ROOT, 'skins'),)

RECAPTCHA_USE_SSL = True

httpd.conf:

#NOTE: the directory paths used here may be adjusted

#the following two directories must be both readable and writable by apache
WSGISocketPrefix /home/whatzzco/domains/whatzz.com/public_html/en/socket
WSGIPythonEggs /var/python/eggs

#the following directory must be readable by apache
WSGIPythonHome /usr/local

#NOTE: all urs below will need to be adjusted if
#settings.FORUM_SCRIPT_ALIAS is anything other than empty string (e.g. = 'forum/')
#this allows "rooting" forum at http://example.com/forum, if you like

#replace with 127.0.0.1 with real IP address
<VirtualHost 194.54.81.222:80>
     ServerAdmin ******@*****.***
     DocumentRoot /home/whatzzco/domains/whatzz.com/public_html/en
     ServerName localhost

     #aliases to serve static media directly
     #will probably need adjustment
     Alias /static/ /home/whatzzco/domains/whatzz.com/public_html/en/static/
     Alias /upfiles/ /home/whatzzco/domains/whatzz.com/public_html/en/askbot/upfiles/
     <DirectoryMatch "/home/whatzzco/domains/whatzz.com/public_html/en/askbot/skins/([^/]+)/media">
        Order deny,allow
        Allow from all
     </DirectoryMatch>
     <Directory "/home/whatzzco/domains/whatzz.com/public_html/en/askbot/upfiles">
        Order deny,allow
        Allow from all
     </Directory>
     #must be a distinct name within your apache configuration
     WSGIDaemonProcess whatzz_en
     WSGIProcessGroup whatzz_en
     WSGIScriptAlias / /home/whatzzco/domains/whatzz.com/public_html/en/django.wsgi
     #make all admin stuff except media go through secure connection
     <LocationMatch "/admin(?!/media)">
     RewriteEngine on
         RewriteRule /admin(.*)$ https://whatzz.com/admin$1 [L,R=301]
         </LocationMatch>
     CustomLog /var/log/httpd/askbot/access_log common
     ErrorLog /var/log/httpd/askbot/error_log
     LogLevel debug
</VirtualHost>
#again, replace the IP address
<VirtualHost 194.54.81.222:443>
     ServerAdmin fucocuso@gmail.com
     DocumentRoot /home/whatzzco/domains/whatzz.com/public_html/en
     ServerName whatzz.com
     <LocationMatch "^(?!/admin)">
         RewriteEngine on
         RewriteRule django.wsgi(.*)$ http://example.com$1 [L,R=301]
     </LocationMatch>
     SSLEngine on
     #your SSL keys
     SSLCertificateFile /etc/httpd/ssl.crt/server.crt
     SSLCertificateKeyFile /etc/httpd/ssl.key/server.key
     Alias /admin/media/ /usr/local/lib/python2.7/dist-packages/django/contrib/admin/media/
     WSGIScriptAlias / /home/whatzzco/domains/whatzz.com/public_html/en/django.wsgi
     CustomLog /var/log/httpd/askbot/access_log common
     ErrorLog /var/log/httpd/askbot/error_log
</VirtualHost>

By the way, I have no idea where do I have to place this httpd.conf. For now it is in my django project path...

Any suggestion would be very helpful.

Thanks.

delete close flag offensive retag edit

Be the first one to answer this question!

Please start posting your answer anonymously - your answer will be saved within the current session and published after you log in or create a new account. Please try to give a substantial answer, for discussions, please use comments and please do remember to vote (after you log in)!

[hide preview]

Reliable Askbot Hosting

Create your Q&A site at askbot.com. Managed Askbot hosting at just $15/mo. Dedicated hosting, support contracts, consulting services.

create your Q&A site
30 days free trial

Question tools

Follow

subscribe to rss feed

Stats

Asked: 2012-05-29 05:21:21 -0500

Seen: 225 times

Last updated: May 29 '12