I am using django socialauth of OMAB, I am using the example works next to the file have not changed anything, but I put it in local_settings.py:
TWITTER_CONSUMER_KEY = 'Mk' this is no real
TWITTER_CONSUMER_SECRET = 'MTw' this is no real
FACEBOOK_APP_ID = ''
FACEBOOK_API_SECRET = ''
LINKEDIN_CONSUMER_KEY = ''
LINKEDIN_CONSUMER_SECRET = ''
ORKUT_CONSUMER_KEY = ''
ORKUT_CONSUMER_SECRET = ''
GOOGLE_OAUTH2_CLIENT_ID = ''
GOOGLE_OAUTH2_CLIENT_SECRET = ''
SOCIAL_AUTH_CREATE_USERS = True
SOCIAL_AUTH_FORCE_RANDOM_USERNAME = False
SOCIAL_AUTH_DEFAULT_USERNAME = 'socialauth_user'
SOCIAL_AUTH_COMPLETE_URL_NAME = 'socialauth_complete'
LOGIN_ERROR_URL = '/login/error/'
#SOCIAL_AUTH_USER_MODEL = 'app.CustomUser'
SOCIAL_AUTH_ERROR_KEY = 'socialauth_error'
GITHUB_APP_ID = ''
GITHUB_API_SECRET = ''
FOURSQUARE_CONSUMER_KEY = ''
FOURSQUARE_CONSUMER_SECRET = ''
this is my settings.py
from os.path import abspath, dirname, basename, join
try:
import social_auth
except ImportError:
import sys
sys.path.insert(0, "..")
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ROOT_PATH = abspath(dirname(__file__))
PROJECT_NAME = basename(ROOT_PATH)
ADMINS = (
# ('Your Name', 'your_email#domain.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'test.db',
}
}
TIME_ZONE = 'America/Chicago'
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
USE_I18N = True
USE_L10N = True
MEDIA_ROOT = ''
ADMIN_MEDIA_PREFIX = '/admin-media/'
MEDIA_URL = ''
SECRET_KEY = 't2eo^kd%k+-##ml3#_x__$j0(ps4p0q6eg*c4ttp9d2n(t!iol'
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.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 = 'example.urls'
TEMPLATE_DIRS = (
join(ROOT_PATH, 'templates')
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'social_auth',
'app',
)
SOCIAL_AUTH_ENABLED_BACKENDS = ('google', 'google-oauth', 'facebook', 'twitter')
AUTHENTICATION_BACKENDS = (
'social_auth.backends.twitter.TwitterBackend',
'social_auth.backends.facebook.FacebookBackend',
'social_auth.backends.google.GoogleOAuthBackend',
'social_auth.backends.google.GoogleOAuth2Backend',
'social_auth.backends.google.GoogleBackend',
'social_auth.backends.yahoo.YahooBackend',
'social_auth.backends.contrib.linkedin.LinkedinBackend',
'social_auth.backends.contrib.flickr.FlickrBackend',
'social_auth.backends.OpenIDBackend',
'social_auth.backends.contrib.livejournal.LiveJournalBackend',
'django.contrib.auth.backends.ModelBackend',
)
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.contrib.messages.context_processors.messages',
'social_auth.context_processors.social_auth_by_type_backends',
)
LOGIN_REDIRECT_URL = '/'
try:
from local_settings import *
except:
pass
I have the same problem as the user tries to rename local_settings.py to local_settings_template.py and does not work and vice versa. This user does not know how to resolved this problem, do not know how to contact you to ask. if someone could test the sample to see if has the same problem would help me a lot.
I was able to get twitter working with the following modifications
settings.py:
AUTHENTICATION_BACKENDS = (
'social_auth.backends.google.TwitterBackend',
)
SOCIAL_AUTH_ENABLED_BACKENDS = ('twitter',)
TWITTER_CONSUMER_KEY = 'xxx'
TWITTER_CONSUMER_SECRET = 'yyy'
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'social_auth',
)
urls.py:
url(r'', include('social_auth.urls')),
Of course this is needed:
% python manage.py syncdb
To test this directly with Twitter (without configuring any other pieces of your project/application), simply browse to /login/twitter and you should go through the authentication dance, your user will be added to the database and you'll be redirected (to a non-existent URL, but you'll have the user information).
From there you should be able to get it working with your system.
Related
I am trying to create a blog using django and mongodb in aws ec2 instance
And in the file models.py, I am making following changes
from datetime import datetime
from mongoengine import *
from mongoengine.django.auth import User
from django.core.urlresolvers import reverse
class Post(Document):
user = ReferenceField(User, reverse_delete_rule=CASCADE)
title = StringField(max_length=200, required=True)
text = StringField(required=True)
text_length = IntField()
date_modified = DateTimeField(default=datetime.now)
is_published = BooleanField()
from django.core.urlresolvers import reverse
class Post(Document):
user = ReferenceField(User, reverse_delete_rule=CASCADE)
title = StringField(max_length=200, required=True)
text = StringField(required=True)
text_length = IntField()
date_modified = DateTimeField(default=datetime.now)
is_published = BooleanField()
def __unicode__(self):
return self.title
def save(self, *args, **kwargs):
self.text_length = len(self.text)
return super(Post, self).save(*args, **kwargs)
def get_absolute_url(self):
return reverse('detail', args=[self.id])
def get_edit_url(self):
return reverse('update', args=[self.id])
def get_delete_url(self):
return reverse('delete', args=[self.id])
And, I get this error
Traceback (most recent call last):
File "models.py", line 7, in <module>
from mongoengine.django.auth import User
ImportError: No module named django.auth
And, in settings.py file, I am making following changes
import os
from mongoengine import *
PROJECT_ROOT = os.path.abspath(os.path.dirname(__file__))
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = ['54.149.63.203', 'localhost', '127.0.0.1']
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'django.contrib.sites',
'LJblog',
'django_extensions',
'mongoengine.django.mongo_auth',
)
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',
'django.middleware.security.SecurityMiddleware',
)
ROOT_URLCONF = 'LJ.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [],
'APP_DIRS': True,
'OPTIONS': {
'context_processors': [
'django.template.context_processors.debug',
'django.template.context_processors.request',
'django.contrib.auth.context_processors.auth',
'django.contrib.messages.context_processors.messages',
],
},
},
]
WSGI_APPLICATION = 'LJ.wsgi.application'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.dummy',
'NAME': '',
'USER': '',
'PASSWORD': '',
'HOST': '55.181.26.33', //mongodb ip address
'PORT': '27017',
}
}
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
MEDIA_ROOT = os.path.join(PROJECT_ROOT, '..', 'media')
MEDIA_URL = '/media/'
STATIC_ROOT = os.path.join(PROJECT_ROOT, '..', 'static')
STATIC_URL = '/static/'
STATICFILES_DIRS = (
os.path.join(PROJECT_ROOT, 'static'),
)
TEMPLATE = (
os.path.join(PROJECT_ROOT, 'templates'),
)
AUTHENTICATION_BACKENDS = (
'mongoengine.django.auth.MongoEngineBackend',
)
SESSION_ENGINE = 'mongoengine.django.sessions'
AUTH_USER_MODEL = 'mongo_auth.MongoUser'
MONGOENGINE_USER_DOCUMENT = 'mongoengine.django.auth.User'
MONGO_DATABASE_NAME = 'LJ_blog'
from mongoengine import connect
connect(MONGO_DATABASE_NAME)
So, how can I resolve the import error?
Django support was removed from MongoEngine in 0.10.0. You might be able to get an earlier version to work, but it might not support recent versions of Django.
With mongoengine 0.10 we can see that
/usr/lib/python2.7/site-packages/mongoengine/
will not have django package in it.
Install mongoengine 0.9 using
sudo pip install mongoengine==0.9
and the django package (support or extension) will be available.
I am able to browse django admin login page but upon keying in correct login details it will stay on the same login page with empty textboxes. It will show messages if login details are wrong though.
I have the following, what ways can I troubleshoot as the log doesn say anything significant.
What the ways to test login on the shell?
Use manage.py createsuperuser to create superuser as I missed the default one during running syncdb
Cleared cookies and retry still the same.
Correct SITE_ID in settings.py
settings.py
import logging
import pwd
import os
DEBUG = True
TEMPLATE_DEBUG = DEBUG
DEBUG_TOOLBAR = False
PROFILER_ON = False
INTERNAL_IPS = (
'127.0.0.1'
)
ADMINS = (
('Admin', 'test#domain.com'),
)
SEND_BROKEN_LINK_EMAILS = False
MANAGERS = ADMINS
DEFAULT_FROM_EMAIL = 'test#domain'
SERVER_EMAIL = DEFAULT_FROM_EMAIL
EMAIL_HOST = 'test'
UPLOAD_ROOT = '/domain/uploads'
PUBLIC_UPLOAD_ROOT = '/domain/htdocs/public_uploads'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'table_name',
'USER': 'username',
'PASSWORD': 'password',
'HOST': 'localhost',
'PORT': '',
# use this to create InnoDB tables
'OPTIONS': {
'init_command': 'SET storage_engine=InnoDB',
'charset': 'utf8',
}
}
}
#SESSION_COOKIE_SECURE = True
# Setup logging
LOGGING = {
'version': 1,
'disable_existing_loggers': True,
}
TIME_ZONE = 'America/Chicago'
LANGUAGE_CODE = 'en-us'
LANGUAGES = (
('en-us', _('English(US)')),
)
SITE_ID = 1
SITE_NAME = 'my site'
USE_I18N = True
MEDIA_ROOT = os.path.join(os.path.dirname(__file__), 'media')
MEDIA_URL = '/media/'
PUBLIC_UPLOAD_URL = '/public_uploads/'
UPLOAD_URL = '/uploads/'
UPLOAD_IMAGES_DIR = 'images/'
ADMIN_MEDIA_PREFIX = '/djangomedia/'
SECRET_KEY = 'test'
#SESSION_COOKIE_HTTPONLY = True
#SESSION_COOKIE_DOMAIN = 'domain'
# 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',
)
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.locale.LocaleMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.transaction.TransactionMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.contrib.flatpages.middleware.FlatpageFallbackMiddleware',
)
LOGIN_URL = '/login/'
LOGIN_REDIRECT_URL = '/users/main/'
# The URL where requests are redirected for logout.
LOGOUT_URL = '/logout/'
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.i18n',
'django.core.context_processors.request',
'django.contrib.messages.context_processors.messages',
)
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
)
ROOT_URLCONF = 'myapp.urls'
TEMPLATE_DIRS = (
os.path.join(os.path.dirname(__file__), 'templates'),
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'django.contrib.admindocs',
'django.contrib.flatpages',
)
urls.py
url(r'^admin/', include(admin.site.urls)),
It was actually due to SESSION_COOKIE_SECURE = True in my settings.py, I had it accidentally defined in 2 places, one commented another one uncommented causing that to happen since the site is not running under https yet. It was silly mistake – user1076881 Apr 5 at 7:27
I've installed Django 1.3 with django-cms. All is working correctly.
After that I installed cmsplugin-blog (from the extensions page of the djanog-cms website), version 1.1.1
I can't seem to get my urls working correctly. It looks like the correct urls are being produced by the blog app, but when opening the posts, I get 404 error. I think it might be a mistake in the urls.py of the blog application:
from django.conf import settings
from django.conf.urls.defaults import *
from django.core.urlresolvers import reverse
from django.views.generic.date_based import archive_year, archive_month, archive_day, object_detail
from django.views.generic.list_detail import object_list
from tagging.views import tagged_object_list
from menus.utils import set_language_changer
from cms.models import Title
from cms.utils.urlutils import urljoin
from cmsplugin_blog.feeds import EntriesFeed, TaggedEntriesFeed, AuthorEntriesFeed
from cmsplugin_blog.models import Entry
from cmsplugin_blog.views import EntryDateDetailView, EntryArchiveIndexView
blog_info_dict = {
'queryset': Entry.objects.all(),
'date_field': 'pub_date',
'allow_empty': True,
'paginate_by': 15,
}
blog_info_tagged_dict = {
'queryset_or_model': Entry.objects.all(),
'allow_empty': True,
}
blog_info_author_dict = {
'queryset': Entry.objects.all(),
'allow_empty': True,
'template_name': 'cmsplugin_blog/entry_author_list.html',
}
blog_info_month_dict = {
'queryset': Entry.objects.all(),
'date_field': 'pub_date',
'month_format': '%m',
'allow_empty': True,
}
blog_info_year_dict = {
'queryset': Entry.objects.all(),
'date_field': 'pub_date',
'make_object_list': True,
'allow_empty': True,
}
blog_info_detail_dict = dict(blog_info_month_dict, slug_field='entrytitle__slug')
def language_changer(lang):
request = language_changer.request
return request.get_full_path()
blog_archive_index = EntryArchiveIndexView.as_view()
def blog_archive_year(request, **kwargs):
kwargs['queryset'] = kwargs['queryset'].published()
set_language_changer(request, language_changer)
return archive_year(request, **kwargs)
def blog_archive_month(request, **kwargs):
kwargs['queryset'] = kwargs['queryset'].published()
set_language_changer(request, language_changer)
return archive_month(request, **kwargs)
def blog_archive_day(request, **kwargs):
kwargs['queryset'] = kwargs['queryset'].published()
set_language_changer(request, language_changer)
return archive_day(request, **kwargs)
blog_detail = EntryDateDetailView.as_view()
def blog_archive_tagged(request, **kwargs):
kwargs['queryset_or_model'] = kwargs['queryset_or_model'].published()
set_language_changer(request, language_changer)
return tagged_object_list(request, **kwargs)
def blog_archive_author(request, **kwargs):
author = kwargs.pop('author')
kwargs['queryset'] = kwargs['queryset'].published().filter(entrytitle__author__username=author)
kwargs['extra_context'] = {
'author': author,
}
set_language_changer(request, language_changer)
return object_list(request, **kwargs)
urlpatterns = patterns('',
(r'^$', blog_archive_index, blog_info_dict, 'blog_archive_index'),
(r'^(?P<year>\d{4})/$',
blog_archive_year, blog_info_year_dict, 'blog_archive_year'),
(r'^(?P<year>\d{4})/(?P<month>\d{2})/$',
blog_archive_month, blog_info_month_dict, 'blog_archive_month'),
(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/$',
blog_archive_day, blog_info_month_dict, 'blog_archive_day'),
(r'^(?P<year>\d{4})/(?P<month>\d{2})/(?P<day>\d{2})/(?P<slug>[-\w]+)/$',
blog_detail, blog_info_detail_dict, 'blog_detail'),
(r'^tagged/(?P<tag>[^/]*)/$', blog_archive_tagged, blog_info_tagged_dict, 'blog_archive_tagged'),
(r'^author/(?P<author>[^/]*)/$', blog_archive_author, blog_info_author_dict, 'blog_archive_author'),
(r'^rss/any/tagged/(?P<tag>[^/]*)/$', TaggedEntriesFeed(), {'any_language': True}, 'blog_rss_any_tagged'),
(r'^rss/tagged/(?P<tag>[^/]*)/$', TaggedEntriesFeed(), {}, 'blog_rss_tagged'),
(r'^rss/any/author/(?P<author>[^/]*)/$', AuthorEntriesFeed(), {'any_language': True}, 'blog_rss_any_author'),
(r'^rss/author/(?P<author>[^/]*)/$', AuthorEntriesFeed(), {}, 'blog_rss_author'),
(r'^rss/any/$', EntriesFeed(), {'any_language': True}, 'blog_rss_any'),
(r'^rss/$', EntriesFeed(), {}, 'blog_rss')
)
Any help is appreciated!
If you need more configurations, I can post them.
Thanks
settings.py
# -*- coding: utf-8 -*-
import os
gettext = lambda s: s
PROJECT_DIR = os.path.abspath(os.path.dirname(__file__))
DEBUG = True
TEMPLATE_DEBUG = DEBUG
MANAGERS = ADMINS
DEFAULT_LANGUAGE = 0
DATABASES = {
'default': {
'ENGINE': '*******',
'NAME': '*******',
'USER': '*******',
'PASSWORD': '*********',
'HOST': '*******',
'PORT': '*******',
}
}
TIME_ZONE = 'Europe/Amsterdam'
LANGUAGE_CODE = 'nl'
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
MEDIA_ROOT = os.path.join(PROJECT_DIR, 'media')
STATIC_ROOT = os.path.join(PROJECT_DIR, 'static')
# 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',
)
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',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.multilingual.MultilingualURLMiddleware',
'cmsplugin_blog.middleware.MultilingualBlogEntriesMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
'django.core.context_processors.i18n',
'django.core.context_processors.request',
'django.core.context_processors.media',
'django.core.context_processors.static',
'cms.context_processors.media',
'sekizai.context_processors.sekizai',
)
CMS_TEMPLATES = (
('base.html', 'Main Template'),
)
ROOT_URLCONF = 'urls'
TEMPLATE_DIRS = (
os.path.join(PROJECT_DIR, 'templates'),
)
#for cms-blog
JQUERY_JS = 'https://ajax.googleapis.com/ajax/libs/jquery/1.4.4/jquery.min.js'
JQUERY_UI_JS = 'https://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/jquery-ui.min.js'
JQUERY_UI_CSS = 'http://ajax.googleapis.com/ajax/libs/jqueryui/1.8.12/themes/smoothness/jquery-ui.css'
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'django.contrib.staticfiles',
'debug_toolbar',
'cms',
'menus',
'mptt',
'south',
'cms.plugins.text',
'cms.plugins.picture',
'cms.plugins.link',
'cms.plugins.file',
'cms.plugins.snippet',
'cms.plugins.googlemap',
'sekizai',
'cmsplugin_contact',
'cmsplugin_blog',
'djangocms_utils',
'simple_translation',
'tagging',
'staticfiles',
)
cms_app.py:
from cms.app_base import CMSApp
from cms.apphook_pool import apphook_pool
from django.utils.translation import ugettext_lazy as _
class BlogApphook(CMSApp):
name = _("Blog Apphook")
urls = ["cmsplugin_blog.urls"]
apphook_pool.register(BlogApphook)
You need to mount the Apphook of the blog app to a page (see http://readthedocs.org/docs/django-cms/en/latest/extending_cms/extending_examples.html#my-first-app-apphook).
You need to do this for every language.
After you do that, you unfortunately have to restart the server.
Never mind. I've found the solution(s)....
After many hours of debugging I found out it was my mistake after all. I am using wsgi and the settings in the apache.wsgi file were incorrect.
In my sys.path I also appended a path from another django project. Since this append was the first one, it was never possible for any of my apps to read the correct settings files and url.py files.
After that it took me some time searching why the zinnia app (I moved from cmsplugin-blog to zinnia, which has much more options) wasn't working. This post helped in the right direction:
http://groups.google.com/group/django-blog-zinnia/browse_thread/thread/4de2827343fb79e0
After I put my url patterns in the correct order, everything worked fine!
I was trying to use django-social-auth today, but turned out I got an error everytime I tried to login using it.
I was using the example found in its git master branch, put in my facebook keys, but when I click to login using facebook, the error "Incorrect authentication service" appears.
That also occurs in twitter and orkut logins... does anyone have any idea why that may be happening?
Thanks a lot!
Edit
Yeah, I'm sorry, I forgot to post my code.
settings.py
from os.path import abspath, dirname, basename, join
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ROOT_PATH = abspath(dirname(__file__))
PROJECT_NAME = basename(ROOT_PATH)
ADMINS = (
# ('Your Name', 'your_email#domain.com'),
)
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'test.db',
}
}
TIME_ZONE = 'America/Chicago'
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
USE_I18N = True
USE_L10N = True
MEDIA_ROOT = ''
ADMIN_MEDIA_PREFIX = '/admin-media/'
MEDIA_URL = ''
SECRET_KEY = '****'
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.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 = 'urls'
TEMPLATE_DIRS = (
join(ROOT_PATH, 'templates')
)
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'social_auth',
'app',
)
AUTHENTICATION_BACKENDS = (
'social_auth.backends.twitter.TwitterBackend',
'social_auth.backends.facebook.FacebookBackend',
'social_auth.backends.google.GoogleOAuthBackend',
'social_auth.backends.google.GoogleOAuth2Backend',
'social_auth.backends.google.GoogleBackend',
'social_auth.backends.yahoo.YahooBackend',
'social_auth.backends.contrib.linkedin.LinkedinBackend',
'social_auth.backends.OpenIDBackend',
'social_auth.backends.contrib.livejournal.LiveJournalBackend',
'django.contrib.auth.backends.ModelBackend',
)
try:
from local_settings import *
except:
pass
local_settings.py
TWITTER_CONSUMER_KEY = ''
TWITTER_CONSUMER_SECRET = ''
FACEBOOK_APP_ID = '226521154024720'
FACEBOOK_API_SECRET = '9955be3b6e211b51921cb4b8eb08e69e'
LINKEDIN_CONSUMER_KEY = ''
LINKEDIN_CONSUMER_SECRET = ''
ORKUT_CONSUMER_KEY = ''
ORKUT_CONSUMER_SECRET = ''
GOOGLE_OAUTH2_CLIENT_KEY = ''
GOOGLE_OAUTH2_CLIENT_SECRET = ''
SOCIAL_AUTH_CREATE_USERS = True
SOCIAL_AUTH_FORCE_RANDOM_USERNAME = False
SOCIAL_AUTH_DEFAULT_USERNAME = 'socialauth_user'
SOCIAL_AUTH_COMPLETE_URL_NAME = 'complete'
LOGIN_ERROR_URL = '/login/error/'
#SOCIAL_AUTH_USER_MODEL = 'app.CustomUser'
SOCIAL_AUTH_ERROR_KEY = 'socialauth_error'
The rest of the codes are exactly the same in example in github.com/omab/django-social-auth
if you need any other code, just tell me.
Thanks a lot!
In my case the problem was that I had FACEBOOK_APP_SECRET instead of FACEBOOK_API_SECRET. It was due to the fact that I migrated from django-facebook to django-social-auth.
It may be you don't have the FACEBOOK_APP_ID or FACEBOOK_API_SECRET set.
Well, without seeing your configuration this will simply be a shot in the dark. But the django-social-auth code has this:
def complete_process(request, backend):
"""Authentication complete process"""
backend = get_backend(backend, request, request.path)
if not backend:
return HttpResponseServerError('Incorrect authentication service')
...
So, offhand, I would guess that you don't have the right backend configured or, at the very least, Django can't find it. Make sure you have the appropriate backend configured in AUTHENTICATION_BACKENDS and that you've obtained the required OAuth keys from the service you want to use.
Keep in mind, too, that this error occurs in the django-social-auth code in a few places, but always when the specified backend can't be retrieved.
I have static.serve setup on my local development server, but it seems to cache static files (in my case, css, javascript and images) until I restart the the server. I am not using apache, and I have the cache set to:
CACHES = {
'default': {
'BACKEND': 'django.core.cache.backends.dummy.DummyCache',
}
}
Removing the caches declaration all together doesn't seem to help either.
This didn't happen before I upgraded to 1.2.5 from an older 1.1 version.
It's a pain to have to restart the dev server every time (either by touching a python file or via the command line) every time I make a style update.
Edit - as suggested, I've added settings.py and url.py
Settings.py
# Django settings for zeiss_elearning project.
from django.utils.translation import ugettext_lazy as _
gettext = lambda s: s
DEBUG = True
TEMPLATE_DEBUG = DEBUG
ADMINS = (
('Jason Roy', '###'),
)
#Email settings
EMAIL_HOST = '###'
EMAIL_HOST_USER = 'info#btbcreative.com'
EMAIL_HOST_PASSWORD = '####'
DEFAULT_FROM_EMAIL = 'info#btbcreative.com'
MANAGERS = ADMINS
DATABASES = {
'default': {
'ENGINE' : 'django.db.backends.mysql',
'NAME' : '###',
'USER' : '###',
'PASSWORD' : '###',
'HOST' : '/Applications/MAMP/tmp/mysql/mysql.sock',
}
}
TIME_ZONE = 'America/Tijuana'
LANGUAGE_CODE = 'en-us'
SITE_ID = 1
USE_I18N = True
USE_L10N = True
MEDIA_DEBUG_DOC_ROOT = '/Users/jason/Bird Takes Bear/Projects/Carl Zeiss/site 2.0/media'
MEDIA_ROOT = '/Users/jason/Bird Takes Bear/Projects/Carl Zeiss/site 2.0/media'
MEDIA_URL = '/static_files/'
ADMIN_MEDIA_PREFIX = '/media/admin/'
# 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.contrib.sessions.middleware.SessionMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.cache.UpdateCacheMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.doc.XViewMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'cms.middleware.page.CurrentPageMiddleware',
'cms.middleware.user.CurrentUserMiddleware',
'cms.middleware.toolbar.ToolbarMiddleware',
'cms.middleware.media.PlaceholderMediaMiddleware',
#'django.middleware.cache.FetchFromCacheMiddleware',
#'debug_toolbar.middleware.DebugToolbarMiddleware',
)
ROOT_URLCONF = 'zeiss_elearning.urls'
TEMPLATE_CONTEXT_PROCESSORS = (
'django.core.context_processors.auth',
'django.core.context_processors.i18n',
'django.core.context_processors.request',
'django.core.context_processors.media',
'cms.context_processors.media',
)
TEMPLATE_DIRS = (,
'/Users/jason/Bird Takes Bear/Projects/Carl Zeiss/site 2.0/templates',
'/Users/jason/Bird Takes Bear/Projects/Carl Zeiss/site 2.0/cms/templates',
)
SESSION_COOKIE_AGE = 86400
LOGIN_URL = '/membership/login/'
LOGIN_REDIRECT_URL = "/"
AUTHENTICATION_BACKENDS = (
'zeiss_elearning.shared.email_auth.EmailBackend',
'django.contrib.auth.backends.ModelBackend',
)
AUTH_PROFILE_MODULE = 'membership.UserProfile'
FORCE_SCRIPT_NAME = ''
INSTALLED_APPS = (
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.admin',
'cms',
'cms.plugins.text',
'cms.plugins.picture',
'cms.plugins.link',
'cms.plugins.file',
'cms.plugins.snippet',
'cms.plugins.googlemap',
'cms.plugins.zeiss_video',
'cms.plugins.html',
'cms.plugins.quiz',
'cms.plugins.popup',
'mptt',
'publisher',
'zeiss_elearning.forms',
'zeiss_elearning.membership',
'zeiss_elearning.quiz',
'menus',
'south',
)
INTERNAL_IPS = ('127.0.0.1',)
#CMS Settings
CMS_REDIRECTS = True
CMS_MENU_TITLE_OVERWRITE = True
CMS_DBGETTEXT = False
CMS_DEFAULT_TEMPLATE = 'base.html'
CMS_ALLOW_HTML_TITLES = False
CMS_TEMPLATES = (
('base.html', _('Default')),
('cirrus.html', _('Cirrus')),
('atlas.html', _('Atlas')),
)
# Site title for your template
CMS_SITE_TITLE = 'Zeiss Cirrus'
CMS_LANGUAGE_REDIRECT = False
CMS_LANGUAGES = (
('en', gettext('English')),
)
LANGUAGES = (
('en', gettext('English')),
)
CMS_APPLICATIONS_URLS = (
('zeiss_elearning.quiz.urls', 'Quiz')
)
urls.py
from django.conf.urls.defaults import *
from django.contrib import admin
from django.conf import settings
admin.autodiscover()
urlpatterns = patterns('',
(r'^membership/', include('zeiss_elearning.membership.urls')),
(r'^admin/', include(admin.site.urls)),
)
urlpatterns += patterns('',
url(r'^', include('cms.urls')),
)
if settings.DEBUG:
urlpatterns += patterns('',
(r'^static_files/(?P<path>.*)$', 'django.views.static.serve',
{'document_root': settings.MEDIA_DEBUG_DOC_ROOT}),)
The bottom line here, based on the data provided, seems to be that your browser is caching the media files. The recommended method to resolve this is super refreshing the pages in your browser. See ALL the comments on your post.
However, If you really do not want the media files to be cached you can simply set them constantly unique names. Like so.
<link rel="stylesheet" type="text/css" href="/site_media/css/style.css?{% now "U" %}" />
Now every time the page is reloaded the filename will be a little bit different based on the unix timestamp, forcing the browser to reload it all the time.