Long time listener, first time caller so let me know if I'm missing any info.
I currently have an AWS EC2 instance running a Django application. My current task has been to perform in-place edits on a table which I have used django-inplaceedit (v 1.4.1). On the development environment I have it up and running but when deployed to staging/production the static (.js and .css) files can't be found. I am running an Apache server but unsure as to how I can get Apache to look where Django has placed these static files.
Due to the pressure to move on to other things, I shamefully copied these files to the app's static folder and have this as a (hopefully temporary fix).
Thanks in advance for the help! : )
PS Here is my app.conf file
WSGIScriptAlias / /home/ubuntu/.virtualenvs/sputnik/sputnik_app/sputnik_app/wsgi.py
WSGIPythonPath /home/ubuntu/.virtualenvs/sputnik/sputnik_app:/home/ubuntu/.virtualenvs/sputnik/lib/python2.7/site-packages
<Directory /home/ubuntu/.virtualenvs/sputnik/sputnik_app/sputnik_app>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
Alias /media/ /home/ubuntu/.virtualenvs/sputnik/sputnik_app/media/
Alias /static/ /home/ubuntu/.virtualenvs/sputnik/sputnik_app/static/
<Directory /home/ubuntu/.virtualenvs/sputnik/sputnik_app/static>
Require all granted
</Directory>
<Directory /home/ubuntu/.virtualenvs/sputnik/sputnik_app/media>
Require all granted
</Directory>
And my settings.py
"""
Django settings for sputnik_app project.
For more information on this file, see
https://docs.djangoproject.com/en/1.7/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.7/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.7/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = 'secret'
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = False
TEMPLATE_DEBUG = False
ALLOWED_HOSTS = ['.mysite.com','.mysite.com.']
ADMINS = ()
MANAGERS = ADMINS
EMAIL_BACKEND = 'django.core.mail.backends.console.EmailBackend'
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.messages',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.staticfiles',
'sputnik',
'allauth',
'allauth.account',
'bootstrapform',
'bootstrap_toolkit',
'inplaceeditform',
)
ACCOUNT_ADAPTER = "sputnik_app.adapters.SputnikAccountAdapter"
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.auth.middleware.SessionAuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'sputnik_app.urls'
WSGI_APPLICATION = 'sputnik_app.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.7/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2',
'NAME': 'users',
'USER': 'user',
'PASSWORD': 'notactuallymypasswordorisit', #seriously, it's not though
'HOST': '',
'PORT': ''
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.7/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
LOCALE_PATHS = (os.path.join(BASE_DIR, 'locale'),)
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.7/howto/static-files/
STATIC_PATH = os.path.join(BASE_DIR, 'static')
#STATIC_ROOT = os.path.join(BASE_DIR, 'static')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
STATIC_PATH,
# STATIC_ROOT,
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
)
# Templates
TEMPLATE_PATH = os.path.join(BASE_DIR, 'templates')
TEMPLATE_CONTEXT_PROCESSORS = (
# Required by `allauth` template tags
'django.core.context_processors.request',
'django.contrib.auth.context_processors.auth',
# Required for inplace editing
'django.core.context_processors.request',
)
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
)
TEMPLATE_PATH = os.path.join(BASE_DIR, 'templates')
TEMPLATE_DIRS = (
TEMPLATE_PATH,
# os.path.join(BASE_DIR, 'templates', 'account'),
)
# Registration
REGISTRATION_OPEN = True
LOGIN_URL = '/accounts/login/'
LOGIN_REDIRECT_URL = '/sputnik/'
LOGOUT_URL = '/sputnik/'
AUTHENTICATION_BACKENDS = (
# Needed to login by username in Django admin, regardless of `allauth`
'django.contrib.auth.backends.ModelBackend',
# `allauth` specific authentication methods, such as login by e-mail
'allauth.account.auth_backends.AuthenticationBackend',
)
# Inplace editting
INPLACEEDIT_EDIT_EMPTY_VALUE = '...'
INPLACEEDIT_AUTO_SAVE = True
INPLACEEDIT_EVENT = 'dblclick'
INPLACEEDIT_DISABLE_CLICK = True # For inplace edit text into a link tag
# INPLACEEDIT_EDIT_MESSAGE_TRANSLATION = 'Write a translation' # transmeta option
INPLACEEDIT_SUCCESS_TEXT = 'Successfully saved'
INPLACEEDIT_UNSAVED_TEXT = 'You have unsaved changes'
INPLACE_ENABLE_CLASS = 'enable'
# DEFAULT_INPLACE_EDIT_OPTIONS = {} # dictionary of the optionals parameters that the templatetag can receive to change its behavior (see the Advanced usage section)
# DEFAULT_INPLACE_EDIT_OPTIONS_ONE_BY_ONE = True # modify the behavior of the DEFAULT_INPLACE_EDIT_OPTIONS usage, if True then it use the default values not specified in your template, if False it uses these options only when the dictionnary is empty (when you do put any options in your template)
# ADAPTOR_INPLACEEDIT_EDIT = 'sputnik.perms.MyAdaptorEditInline' # Explain in Permission Adaptor API
# ADAPTOR_INPLACEEDIT = {'myadaptor': 'sputnik.fields.MyAdaptor'} # Explain in Adaptor API
# INPLACE_GET_FIELD_URL = None # to change the url where django-inplaceedit use to get a field
# INPLACE_SAVE_URL = None # to change the url where django-inplaceedit use to save a field
# Sites
SITE_ID = 1
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
try:
from local_settings import *
except ImportError:
pass
EDIT:
I am also a relative n00b when it comes to Django, AWS and Apache
Related
I have created a Django account which uses Dajaxice and Dajax.
I run my website in an azure VM. When I run it with localhost Dajaxice/Dajax work perfectly.
However, online this does not work anymore. I have some configurations problems in my settings, but I am unable to fix it.
Locally, Dajaxice/Dajax is pointed in this way:
<script src="/static/dajaxice/dajaxice.core.js" type="text/javascript" charset="utf-8"></script>
The Dajaxice/Dajax function is called like this:
GET http://localhost:1465/dajaxice/chocolate.chocolate.cellphone/?argv=%7B%22cell%22%3A%22jk%22%2C%22pID%22%3A%228353%22%7D
How should I change my settings, so I can access dajaxice online?
This is my settings.py so far:
from os import path
PROJECT_ROOT = path.dirname(path.abspath(path.dirname(__file__)))
LOGIN_REDIRECT_URL = ''
HTMLFILES_DIR = 'C:\inetpub\wwwroot\chocolate\chocolate\chocolate\htmlFiles'
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
('x', 'x#gmail.com'),
)
SESSION_EXPIRE_AT_BROWSER_CLOSE = True
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
'django.core.context_processors.i18n',
'django.core.context_processors.media',
'django.core.context_processors.static',
'django.core.context_processors.request',
'django.contrib.messages.context_processors.messages',
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'NAME': 'xx',
'ENGINE': 'x',
'HOST': 'x.x.x',
'USER': 'x#zx',
'PASSWORD': 'x!',
'OPTIONS': {
'provider': 'x'
}
}
}
TIME_ZONE = 'Europe/London'
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
USE_I18N = True
USE_L10N = True
USE_TZ = True
MEDIA_ROOT = HTMLFILES_DIR + '\Pictures'
MEDIA_URL = 'http://localhost:1781/Pictures/'
STATIC_ROOT = ''
STATIC_URL = '/static/'
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'dajaxice.finders.DajaxiceFinder',
)
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'xxxxxxxxxxxxxxxxxx'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
'django.template.loaders.eggs.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'chocolate.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'chocolate.wsgi.application'
TEMPLATE_DIRS = (
HTMLFILES_DIR
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'chocolate.chocolate',
'dajaxice',
'dajax',
# Uncomment the next line to enable the admin:
'django.contrib.admin'
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)
EMAIL_HOST = 'smtp-mail.outlook.com'
EMAIL_HOST_USER = 'x#outlook.com'
EMAIL_HOST_PASSWORD = 'x'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
},
'console':{
'level':'INFO',
'class':'logging.StreamHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
'dajaxice':{
'handlers': ['console'],
'level': 'INFO',
'propagate': True,
},
}
}
Well, I found how to do it. For anyone with few experience in Django, this information could be helpful.
When I use localhost, having the following information is just fine:
STATIC_ROOT = ''
STATIC_URL = '/static/'
However, once you plan to deploy your application, you need to create a file somewhere in your application and include the path in STATIC_ROOT. In my case, it was the following:
STATIC_ROOT = 'C:/inetpub/wwwroot/chocolate/chocolate/chocolate/static/'
I manually created the file called static, which you can see above. Then, add the name of the file created in STATIC_URL.
STATIC_URL = '/static/'
Afterwards, with your console access the file where you have your app's manage.py . Make sure to have added python as a command and write python manage.py collectstatic . All your static files will located there, in the static file you created. In my case, the files of dajaxice and dajax appeared in this folder after having written python manage.py collectstatic.
Now, dajaxice/dajax should work online after deployment.
Is there a way to maintain same django settings.py in both Heroku and windows local systemI am using postgres database. I believe it is only the DATABASE_URL set as environment variable in Heroku that is making the difference. Is there some way I could make this work in Windows by setting DATABASE_URL in the environment? Or correct if am wrong here. I tried setting the DATABASE_URL in windows by setting:
set DATABASE_URL='postgres://[DB_USER]:[DB_PASS]#localhost:5432/[DBNAME]
But it is not working, I am getting error when I run syncdb - "ImproperlyConfigured: settings.DATABASES is improperly configured. Please supply the ENGINE value. Check settings documentation for more details.". below is my settings.py file:
# Django settings for triplanner project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email#example.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.postgresql_psycopg2', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': 'triplanner', # Or path to database file if using sqlite3.
# The following settings are not used with sqlite3:
'USER': 'akk',
'PASSWORD': 'admin',
'HOST': '', # Empty for localhost through domain sockets or '127.0.0.1' for localhost through TCP.
'PORT': '', # Set to empty string for default.
}
}
import dj_database_url
DATABASES['default'] = dj_database_url.config()
SECURE_PROXY_SSL_HEADER = ('HTTP_X_FORWARDED_PROTO', 'https')
# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = ['*']
# 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.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'America/Chicago'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
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
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True
# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/var/www/example.com/media/"
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://example.com/media/", "http://media.example.com/"
MEDIA_URL = ''
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/"
import os
BASE_DIR = os.path.dirname(os.path.abspath(__file__))
STATIC_ROOT = 'staticfiles'
# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/'
# Additional locations of static files
STATICFILES_DIRS = (
os.path.join(BASE_DIR,'static')
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'w+anq)bguzp0j2d-il*2nbvtwj^f1s4_exq#u)d!^z2ccc=)(3'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'triplanner.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'triplanner.wsgi.application'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'registration',
# Uncomment the next line to enable the admin:
# 'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)
####### Begin Of Arguments specific to django-registration application ############
ACCOUNT_ACTIVATION_DAYS = 7
EMAIL_HOST = 'localhost'
DEFAULT_FROM_EMAIL = 'akash#localhost.com'
LOGIN_REDIRECT_URL = '/'
####### End Of Arguments specific to django-registration application ############
####### Begin Of Arguments specific to Invitation application ############
ACCOUNT_ACTIVATION_DAYS = 7
ACCOUNT_INVITATION_DAYS = 7
INVITATIONS_PER_USER = 3
INVITE_MODE = True
####### End Of Arguments specific to Invitation application ############
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
Basically should work. Try setting DATABASE_URL in a file called .env which you place next to your Procfile. Foreman will find it and use it when running your processes. The syntax is simply DATABASE_URL=..., without any quotes, and without the word "set", etc.
I'm having difficulty using Django-AllAuth in my own project, as the title suggests. I'm using south, but am new to south, so that can be the source of my problems. Below I'll detail the steps I took and where I am right now.
First, I moved the allauth folder to the root of the project.
Then, I moved the example code's templates to our startup app - I made the "plain/example/index.html" template our startup template (127.0.0.1:8000).
In our project's urls, I added:
#Allauth stuff:
url(r'^accounts/profile/$', TemplateView.as_view(template_name='plain/example/profile.html')),
url(r'^accounts/', include('allauth.urls')),
And project settings look like this:
# Django settings for penguin project.
import os
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email#example.com'),
)
MANAGERS = ADMINS
db_path = os.path.abspath(os.path.join(os.path.abspath(__file__),'..','..','..','db','peng.db'))
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3', # Add 'postgresql_psycopg2', 'mysql', 'sqlite3' or 'oracle'.
'NAME': db_path,# Or path to database file if using sqlite3.
'USER': '', # Not used with sqlite3.
'PASSWORD': '', # Not used with sqlite3.
'HOST': '', # Set to empty string for localhost. Not used with sqlite3.
'PORT': '', # Set to empty string for default. Not used with sqlite3.
}
}
# 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.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'America/Chicago'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
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
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True
# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = ''
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
os.path.abspath(os.path.join(os.path.dirname(__file__),'..', '..', 'static')).replace('\\','/'),
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
# Make this unique, 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.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
'penguin.libs.utilities.import_middle.ImportXMLMiddleware',
)
ROOT_URLCONF = 'penguin.urls'
AUTHENTICATION_BACKENDS = (
"allauth.account.auth_backends.AuthenticationBackend",
)
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'penguin.wsgi.application'
TEMPLATE_DIRS = (
#absolute path, use / even on Windows
os.path.abspath(os.path.join(os.path.dirname(__file__),'..','..')).replace('\\','/')
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
'penguin.apps.royal',
'penguin.apps.blackboard',
'penguin.libs.topic',
'penguin.libs.sidebar',
'penguin.libs.module',
#'penguin.libs.users',
'penguin.apps.messages',
'penguin.apps.profiles',
'penguin.libs.users',
'south',
'allauth',
'allauth.account',
'allauth.socialaccount',
#'allauth.socialaccount.providers.dropbox',
'allauth.socialaccount.providers.facebook',
#'allauth.socialaccount.providers.google',
#'allauth.socialaccount.providers.github',
#'allauth.socialaccount.providers.linkedin',
#'allauth.socialaccount.providers.openid',
#'allauth.socialaccount.providers.persona',
#'allauth.socialaccount.providers.soundcloud',
#'allauth.socialaccount.providers.stackexchange',
#'allauth.socialaccount.providers.twitch',
#'allauth.socialaccount.providers.twitter',
#'allauth.socialaccount.providers.vimeo',
#'allauth.socialaccount.providers.weibo',
)
TEMPLATE_CONTEXT_PROCESSORS = (
"django.contrib.auth.context_processors.auth",
"django.core.context_processors.debug",
"django.core.context_processors.i18n",
"django.core.context_processors.media",
"django.core.context_processors.static",
"django.core.context_processors.request",
"django.contrib.messages.context_processors.messages",
"allauth.account.context_processors.account",
"allauth.socialaccount.context_processors.socialaccount",
)
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
I syncdb, and I run the project.
When I try to go to social accounts on admin, though, I'm getting the following error:
DatabaseError at /admin/socialaccount/socialaccount/
no such table: socialaccount_socialaccount
I believe this problem is being caused by a problem with south. When I syncdb, I get the following response:
Syncing...
Creating tables ...
Installing custom SQL ...
Installing indexes ...
Installed 0 object(s) from 0 fixture(s)
Synced:
> django.contrib.auth
> django.contrib.contenttypes
> django.contrib.sessions
> django.contrib.sites
> django.contrib.messages
> django.contrib.staticfiles
> django.contrib.admin
> penguin.apps.royal
> penguin.apps.blackboard
> penguin.libs.topic
> penguin.libs.sidebar
> penguin.libs.module
> penguin.apps.messages
> penguin.apps.profiles
> penguin.libs.users
> south
> allauth
> allauth.account
Not synced (use migrations):
- allauth.socialaccount
- allauth.socialaccount.providers.facebook
As I am new to South (but have to use it for this project), I don't know how to solve this exactly. I read online that I could do:
migrate socialaccount 0007 --fake
But after doing this, the problem persists.
Does anyone know how to solve this problem, or what causes it? If anyone has any more questions, I can provide any information needed.
I have a problem adding Tastypie to installed apps (I'm not importing anything from Tastypie in any module). When I use Python 3.3 I get an error:
SyntaxError: (unicode error) 'unicodeescape' codec can't decode bytes in position 709-712: truncated \uXXXX escape (validate_jsonp.py, line 207).
With Python 2.7 everything is ok. Where's the problem?
settings.py:
# Django settings for Intro project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email#example.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': '', # Or path to database file if using sqlite3.
# The following settings are not used with sqlite3:
'USER': '',
'PASSWORD': '',
'HOST': '', # Empty for localhost through domain sockets
'PORT': '', # Set to empty string for default.
}
}
# Hosts/domain names that are valid for this site; required if DEBUG is False
# See https://docs.djangoproject.com/en/1.5/ref/settings/#allowed-hosts
ALLOWED_HOSTS = []
# 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.
# In a Windows environment this must be set to your system time zone.
TIME_ZONE = 'Europe/Warsaw'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
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
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale.
USE_L10N = True
# If you set this to False, Django will not use timezone-aware datetimes.
USE_TZ = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/var/www/example.com/media/"
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://example.com/media/", "http://media.example.com/"
MEDIA_URL = ''
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/var/www/example.com/static/"
STATIC_ROOT = ''
# URL prefix for static files.
# Example: "http://example.com/static/", "http://static.example.com/"
STATIC_URL = '/static/'
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
# Make this unique, and don't share it with anybody.
SECRET_KEY = 'qkb#4gs4ph$(4j1+0a96uc2%ap#bbvhx1a0ow%efj^!n)*e&^v'
# List of callables that know how to import templates from various sources.
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
# Uncomment the next line for simple clickjacking protection:
# 'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'Intro.urls'
# Python dotted path to the WSGI application used by Django's runserver.
WSGI_APPLICATION = 'Intro.wsgi.application'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'south',
'tastypie'
# Uncomment the next line to enable the admin:
# 'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
# 'django.contrib.admindocs',
)
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error when DEBUG=False.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'filters': {
'require_debug_false': {
'()': 'django.utils.log.RequireDebugFalse'
}
},
'handlers': {
'mail_admins': {
'level': 'ERROR',
'filters': ['require_debug_false'],
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
i have this error with django riak engine :
django.core.exceptions.ImproperlyConfigured: 'django_riak_engine.riak' isn't an
available database backend.
Try using django.db.backends.XXX, where XXX is one of:
I've installed all the dependencies needed.
Here is my settings.py :
# Django settings for Lin project.
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
# ('Your Name', 'your_email#example.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django_riak_engine.riak',
'NAME': 'mydatabase',
'USER': '',
'PASSWORD': '',
'HOST': 'localhost',
'PORT': '8091',
'SUPPORTS_TRANSACTIONS': 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'
# Language code for this installation. All choices can be found here:
# http://www.i18nguy.com/unicode/language-identifiers.html
LANGUAGE_CODE = 'en-us'
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
# If you set this to False, Django will not format dates, numbers and
# calendars according to the current locale
USE_L10N = True
# Absolute filesystem path to the directory that will hold user-uploaded files.
# Example: "/home/media/media.lawrence.com/media/"
MEDIA_ROOT = ''
# URL that handles the media served from MEDIA_ROOT. Make sure to use a
# trailing slash.
# Examples: "http://media.lawrence.com/media/", "http://example.com/media/"
MEDIA_URL = ''
# Absolute path to the directory static files should be collected to.
# Don't put anything in this directory yourself; store your static files
# in apps' "static/" subdirectories and in STATICFILES_DIRS.
# Example: "/home/media/media.lawrence.com/static/"
STATIC_ROOT = ''
# URL prefix for static files.
# Example: "http://media.lawrence.com/static/"
STATIC_URL = '/static/'
# URL prefix for admin static files -- CSS, JavaScript and images.
# Make sure to use a trailing slash.
# Examples: "http://foo.com/static/admin/", "/static/admin/".
ADMIN_MEDIA_PREFIX = '/static/admin/'
# Additional locations of static files
STATICFILES_DIRS = (
# Put strings here, like "/home/html/static" or "C:/www/django/static".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
# List of finder classes that know how to find static files in
# various locations.
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
)
# Make this unique, 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.Loader',
'django.template.loaders.app_directories.Loader',
# 'django.template.loaders.eggs.Loader',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)
ROOT_URLCONF = 'Lin.urls'
TEMPLATE_DIRS = (
# Put strings here, like "/home/html/django_templates" or "C:/www/django/templates".
# Always use forward slashes, even on Windows.
# Don't forget to use absolute paths, not relative paths.
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
# Uncomment the next line to enable the admin:
'django.contrib.admin',
# Uncomment the next line to enable admin documentation:
'django.contrib.admindocs',
'contacts',
)
# A sample logging configuration. The only tangible logging
# performed by this configuration is to send an email to
# the site admins on every HTTP 500 error.
# See http://docs.djangoproject.com/en/dev/topics/logging for
# more details on how to customize your logging configuration.
LOGGING = {
'version': 1,
'disable_existing_loggers': False,
'handlers': {
'mail_admins': {
'level': 'ERROR',
'class': 'django.utils.log.AdminEmailHandler'
}
},
'loggers': {
'django.request': {
'handlers': ['mail_admins'],
'level': 'ERROR',
'propagate': True,
},
}
}
Have you any idea ?
regards
Bussiere
Did you install all dependencies? From a standard Python shell try
from django_riak_engine import riak
and see if you get errors.