Tuesday 15 February 2011

django - Python Social Auth- import error when using Google Authentication -



django - Python Social Auth- import error when using Google Authentication -

i followed along blog entry more month ago:http://www.artandlogic.com/blog/2014/04/tutorial-adding-facebooktwittergoogle-authentication-to-a-django-application/

when created new environment, , recreated steps, i'm getting import error, no module named google_auth during template rendering.

it traces line:

<a href="{% url 'social:begin' 'google-oauth2' %}?next={{ request.path }}">login</a>

it looks django not looking in social app right template processing? ideas on why no longer working?

#settings.py installed_apps = (... , 'social.apps.django_app.default', ...) authentication_backends = ('social.backends.google.googleoauth2', '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.core.context_processors.static', 'django.core.context_processors.tz', 'django.contrib.messages.context_processors.messages', 'social.apps.django_app.context_processors.backends', 'social.apps.django_app.context_processors.login_redirect') #urls.py urlpatterns = patterns('', url('', include('social.apps.django_app.urls', namespace='social')), url('', include('django.contrib.auth.urls', namespace='auth')), url(r'^$', 'app.views.home', name='home'), ) edit: total traceback below environment: request method: django version: 1.7 python version: 2.7.8 installed applications: ('django.contrib.admin', 'django.contrib.auth', 'django.contrib.contenttypes', 'django.contrib.sessions', 'django.contrib.messages', 'django.contrib.staticfiles', 'charts', 'social.apps.django_app.default', 'djcelery', 'kombu.transport.django') installed middleware: ('django.contrib.sessions.middleware.sessionmiddleware', 'django.middleware.common.commonmiddleware', 'django.middleware.csrf.csrfviewmiddleware', 'django.contrib.auth.middleware.authenticationmiddleware', 'django.contrib.messages.middleware.messagemiddleware', 'django.middleware.clickjacking.xframeoptionsmiddleware', 'social.apps.django_app.middleware.socialauthexceptionmiddleware', 'charts.middleware.socialauthexceptionmiddleware') template error: in template charts/templates/base.html, error @ line 69 no module named google_auth 59 : </ul> 60 : </li> 61 : <li> 62 : hello, <strong>{{ user.get_full_name|default:user.username }}</strong>! 63 : </li> 64 : <li> 65 : <a href="{% url 'auth:logout' %}?next={{ request.path }}">logout</a> 66 : </li> 67 : {% else %} 68 : <li> 69 : <a href=" {% url 'social:begin' 'google-oauth2' %} ?next={{ request.path }}">login</a> 70 : </li> 71 : {% endif %} 72 : </ul> 73 : </nav> 74 : </head> 75 : <body> 76 : {% block content %} 77 : {% endblock %} 78 : <div id="footer"> 79 : <center> traceback: file "//anaconda/envs/analytics/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response 111. response = wrapped_callback(request, *callback_args, **callback_kwargs) file "/charts/views.py" in home 743. context_instance=context) file "//anaconda/envs/analytics/lib/python2.7/site-packages/django/shortcuts.py" in render_to_response 23. homecoming httpresponse(loader.render_to_string(*args, **kwargs), **httpresponse_kwargs) file "//anaconda/envs/analytics/lib/python2.7/site-packages/django/template/loader.py" in render_to_string 174. homecoming t.render(context_instance) file "//anaconda/envs/analytics/lib/python2.7/site-packages/django/template/base.py" in render 148. homecoming self._render(context) file "//anaconda/envs/analytics/lib/python2.7/site-packages/django/template/base.py" in _render 142. homecoming self.nodelist.render(context) file "//anaconda/envs/analytics/lib/python2.7/site-packages/django/template/base.py" in render 844. bit = self.render_node(node, context) file "//anaconda/envs/analytics/lib/python2.7/site-packages/django/template/debug.py" in render_node 80. homecoming node.render(context) file "//anaconda/envs/analytics/lib/python2.7/site-packages/django/template/loader_tags.py" in render 126. homecoming compiled_parent._render(context) file "//anaconda/envs/analytics/lib/python2.7/site-packages/django/template/base.py" in _render 142. homecoming self.nodelist.render(context) file "//anaconda/envs/analytics/lib/python2.7/site-packages/django/template/base.py" in render 844. bit = self.render_node(node, context) file "//anaconda/envs/analytics/lib/python2.7/site-packages/django/template/debug.py" in render_node 80. homecoming node.render(context) file "//anaconda/envs/analytics/lib/python2.7/site-packages/django/template/defaulttags.py" in render 312. homecoming nodelist.render(context) file "//anaconda/envs/analytics/lib/python2.7/site-packages/django/template/base.py" in render 844. bit = self.render_node(node, context) file "//anaconda/envs/analytics/lib/python2.7/site-packages/django/template/debug.py" in render_node 80. homecoming node.render(context) file "//anaconda/envs/analytics/lib/python2.7/site-packages/django/template/defaulttags.py" in render 444. url = reverse(view_name, args=args, kwargs=kwargs, current_app=context.current_app) file "//anaconda/envs/analytics/lib/python2.7/site-packages/django/core/urlresolvers.py" in reverse 517. app_list = resolver.app_dict[ns] file "//anaconda/envs/analytics/lib/python2.7/site-packages/django/core/urlresolvers.py" in app_dict 329. self._populate() file "//anaconda/envs/analytics/lib/python2.7/site-packages/django/core/urlresolvers.py" in _populate 303. lookups.appendlist(pattern.callback, (bits, p_pattern, pattern.default_args)) file "//anaconda/envs/analytics/lib/python2.7/site-packages/django/core/urlresolvers.py" in callback 231. self._callback = get_callable(self._callback_str) file "//anaconda/envs/analytics/lib/python2.7/site-packages/django/utils/lru_cache.py" in wrapper 101. result = user_function(*args, **kwds) file "//anaconda/envs/analytics/lib/python2.7/site-packages/django/core/urlresolvers.py" in get_callable 101. not module_has_submodule(import_module(parentmod), submod)): file "//anaconda/envs/analytics/lib/python2.7/importlib/__init__.py" in import_module 37. __import__(name) exception type: importerror @ / exception value: no module named google_auth

if alternative you, propose utilize django-allauth instead. used both django-allauth , python social auth , find much easier work django-allauth. if have chance, give try

python django python-social-auth

No comments:

Post a Comment