[SOLVED]Django smtp gmail not working in production - django

I'm using django to send email through gmail smtp. It only works, however, before deployment. In production or deployment whatever you call, when I try to send email it keep being loaded forever and only says 'Server Error 500'.
Below is part of my settings.py
EMAIL_BACKEND = 'django.core.mail.backends.smtp.EmailBackend'
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_USE_TLS = True
EMAIL_HOST_USER = config['EMAIL_USER']
EMAIL_HOST_PASSWORD = config['EMAIL_PASS']
Below is .../django_project/users/views.py
from django.shortcuts import render, redirect
from django.contrib import messages
from django.contrib.auth.decorators import login_required
from .forms import UserRegisterForm, UserUpdateForm, ProfileUpdateForm
def register(request):
if request.method == 'POST':
form = UserRegisterForm(request.POST)
if form.is_valid():
form.save()
username = form.cleaned_data.get('username')
messages.success(request, f'Your account has been created! You are now able to log in.')
return redirect('login')
else:
form = UserRegisterForm()
return render(request, 'users/register.html', {'form': form})
#login_required()
def profile(request):
if request.method == 'POST':
u_form = UserUpdateForm(request.POST, instance=request.user)
p_form = ProfileUpdateForm(request.POST,
request.FILES,
instance=request.user.profile)
if u_form.is_valid() and p_form.is_valid():
u_form.save()
p_form.save()
messages.success(request, f'Your account has been updated!')
return redirect('profile')
else:
u_form = UserUpdateForm(instance=request.user)
p_form = ProfileUpdateForm(instance=request.user.profile)
context = {
'u_form': u_form,
'p_form': p_form
}
return render(request, 'users/profile.html', context)
What's confusing is my tutorial videos didn't put any from django.core.mail import send_mail or something. So I'm not sure whether the view.py above is the one that should be shown.
Perhaps this issue is with Gmail itself. Please let me know how can I solve this. Thanks.
EDITED
I briefly set DEBUG = True and saw error messages from error.log.
[Tue Feb 18 12:10:04.400741 2020] [core:notice] [pid 11826:tid 139852027644992] AH00094: Command line: '/usr/sbin/apache2'
[Tue Feb 18 12:15:05.589207 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] Internal Server Error: /password-reset/
[Tue Feb 18 12:15:05.589265 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] Traceback (most recent call last):
[Tue Feb 18 12:15:05.589270 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/core/handlers/exception.py", line 34, in inner
[Tue Feb 18 12:15:05.589274 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] response = get_response(request)
[Tue Feb 18 12:15:05.589278 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 115, in _get_response
[Tue Feb 18 12:15:05.589282 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] response = self.process_exception_by_middleware(e, request)
[Tue Feb 18 12:15:05.589286 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/core/handlers/base.py", line 113, in _get_response
[Tue Feb 18 12:15:05.589290 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Tue Feb 18 12:15:05.589294 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/views/generic/base.py", line 71, in view
[Tue Feb 18 12:15:05.589298 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] return self.dispatch(request, *args, **kwargs)
[Tue Feb 18 12:15:05.589301 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/utils/decorators.py", line 43, in _wrapper
[Tue Feb 18 12:15:05.589305 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] return bound_method(*args, **kwargs)
[Tue Feb 18 12:15:05.589309 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/utils/decorators.py", line 130, in _wrapped_view
[Tue Feb 18 12:15:05.589313 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] response = view_func(request, *args, **kwargs)
[Tue Feb 18 12:15:05.589316 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/contrib/auth/views.py", line 222, in dispatch
[Tue Feb 18 12:15:05.589320 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] return super().dispatch(*args, **kwargs)
[Tue Feb 18 12:15:05.589324 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/views/generic/base.py", line 97, in dispatch
[Tue Feb 18 12:15:05.589327 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] return handler(request, *args, **kwargs)
[Tue Feb 18 12:15:05.589331 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/views/generic/edit.py", line 142, in post
[Tue Feb 18 12:15:05.589335 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] return self.form_valid(form)
[Tue Feb 18 12:15:05.590890 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/contrib/auth/views.py", line 235, in form_valid
[Tue Feb 18 12:15:05.590901 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] form.save(**opts)
[Tue Feb 18 12:15:05.590905 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/contrib/auth/forms.py", line 324, in save
[Tue Feb 18 12:15:05.590909 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] user_email, html_email_template_name=html_email_template_name,
[Tue Feb 18 12:15:05.590913 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/contrib/auth/forms.py", line 272, in send_mail
[Tue Feb 18 12:15:05.590916 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] email_message.send()
[Tue Feb 18 12:15:05.590920 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/core/mail/message.py", line 276, in send
[Tue Feb 18 12:15:05.590923 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] return self.get_connection(fail_silently).send_messages([self])
[Tue Feb 18 12:15:05.590927 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 102, in send_messages
[Tue Feb 18 12:15:05.590930 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] new_conn_created = self.open()
[Tue Feb 18 12:15:05.590934 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] File "/home/djtu/django_project/venv/lib/python3.7/site-packages/django/core/mail/backends/smtp.py", line 62, in open
[Tue Feb 18 12:15:05.590942 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] self.connection = self.connection_class(self.host, self.port, **connection_params)
[Tue Feb 18 12:15:05.590946 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] File "/usr/lib/python3.7/smtplib.py", line 251, in __init__
[Tue Feb 18 12:15:05.590949 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] (code, msg) = self.connect(host, port)
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
[Tue Feb 18 12:15:05.590953 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] File "/usr/lib/python3.7/smtplib.py", line 336, in connect
[Tue Feb 18 12:15:05.590956 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] self.sock = self._get_socket(host, port, self.timeout)
[Tue Feb 18 12:15:05.590960 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] File "/usr/lib/python3.7/smtplib.py", line 307, in _get_socket
[Tue Feb 18 12:15:05.590963 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] self.source_address)
[Tue Feb 18 12:15:05.590966 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] File "/usr/lib/python3.7/socket.py", line 727, in create_connection
[Tue Feb 18 12:15:05.590970 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] raise err
[Tue Feb 18 12:15:05.590973 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] File "/usr/lib/python3.7/socket.py", line 716, in create_connection
[Tue Feb 18 12:15:05.590976 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] sock.connect(sa)
[Tue Feb 18 12:15:05.590980 2020] [wsgi:error] [pid 11827:tid 139851910838016] [remote 121.131.97.11:49984] TimeoutError: [Errno 110] Connection timed out
I hope this log will give some clarification on what went wrong. Can somebody point me out to right direction?
EDITED #2
Thanks to Sachin. I tried as suggested, but my server machine failed to connect. Instead it show this messages.
(venv) myusername#hostname:~$ telnet smtp.gmail.com 587
Trying 2404:6800:4008:c00::6d...
Trying 108.177.97.109...
telnet: Unable to connect to remote host: Connection timed out
Still the issue remains unfortunately.

After some time I realized what went wrong. I use 2-step verification for my gmail account, which means my password won't work in external program like django, unless I replace it with app password.
For more info, please visit official page for app password:
https://support.google.com/accounts/answer/185833?hl=en
And if you're using linode for web hosting company, they might block email port for some reasons, so it could be external problem too.

Related

import name patterns issue with django

After digging I cannot manage to understand what happened with our server. I got this error when loading the web.
It was working and anyone touch anything. I have changed the ownership of the application.txt because this error.
[Wed Dec 16 04:38:12.059839 2020] [wsgi:error] [pid 12343:tid 140072894818048] [remote xx.xx.xxx.xx:xxxxx] ValueError: Unable to configure handler 'file': [Errno 13] Permission denied: '/opt/yhmp-app/YHMP/eamena/logs/application.txt'
After this it is showing up the next error in the browser:
and all this is coming form the error.log when trying to access:
ed Dec 16 13:05:46.856703 2020] [authz_core:debug] [pid 14049:tid 140483607127808] mod_authz_core.c(809): [client] AH01626: authorization result of Require all granted: granted
[Wed Dec 16 13:05:46.856746 2020] [authz_core:debug] [pid 14049:tid 140483607127808] mod_authz_core.c(809): [client ] AH01626: authorization result of <RequireAny>: granted
[Wed Dec 16 13:05:46.856782 2020] [authz_core:debug] [pid 14049:tid 140483607127808] mod_authz_core.c(809): [client :56384] AH01626: authorization result of Require all granted: granted
[Wed Dec 16 13:05:46.856787 2020] [authz_core:debug] [pid 14049:tid 140483607127808] mod_authz_core.c(809): [client :56384] AH01626: authorization result of <RequireAny>: granted
[Wed Dec 16 07:05:46.857793 2020] [wsgi:error] [pid 14047:tid 140483690739456] Internal Server Error: /
[Wed Dec 16 07:05:46.857809 2020] [wsgi:error] [pid 14047:tid 140483690739456] Traceback (most recent call last):
[Wed Dec 16 07:05:46.857814 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
[Wed Dec 16 07:05:46.857817 2020] [wsgi:error] [pid 14047:tid 140483690739456] response = get_response(request)
[Wed Dec 16 07:05:46.857821 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/core/handlers/base.py", line 244, in _legacy_get_response
[Wed Dec 16 07:05:46.857824 2020] [wsgi:error] [pid 14047:tid 140483690739456] response = middleware_method(request)
[Wed Dec 16 07:05:46.857828 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/middleware/locale.py", line 24, in process_request
[Wed Dec 16 07:05:46.857831 2020] [wsgi:error] [pid 14047:tid 140483690739456] i18n_patterns_used, prefixed_default_language = is_language_prefix_patterns_used(urlconf)
[Wed Dec 16 07:05:46.857834 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/utils/lru_cache.py", line 100, in wrapper
[Wed Dec 16 07:05:46.857838 2020] [wsgi:error] [pid 14047:tid 140483690739456] result = user_function(*args, **kwds)
[Wed Dec 16 07:05:46.857841 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/conf/urls/i18n.py", line 29, in is_language_prefix_patterns_used
[Wed Dec 16 07:05:46.857844 2020] [wsgi:error] [pid 14047:tid 140483690739456] for url_pattern in get_resolver(urlconf).url_patterns:
[Wed Dec 16 07:05:46.857847 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
[Wed Dec 16 07:05:46.857857 2020] [wsgi:error] [pid 14047:tid 140483690739456] res = instance.__dict__[self.name] = self.func(instance)
[Wed Dec 16 07:05:46.857861 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/urls/resolvers.py", line 407, in url_patterns
[Wed Dec 16 07:05:46.857865 2020] [wsgi:error] [pid 14047:tid 140483690739456] patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
[Wed Dec 16 07:05:46.857868 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
[Wed Dec 16 07:05:46.857871 2020] [wsgi:error] [pid 14047:tid 140483690739456] res = instance.__dict__[self.name] = self.func(instance)
[Wed Dec 16 07:05:46.857874 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/urls/resolvers.py", line 400, in urlconf_module
[Wed Dec 16 07:05:46.857877 2020] [wsgi:error] [pid 14047:tid 140483690739456] return import_module(self.urlconf_name)
[Wed Dec 16 07:05:46.857880 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
[Wed Dec 16 07:05:46.857883 2020] [wsgi:error] [pid 14047:tid 140483690739456] __import__(name)
[Wed Dec 16 07:05:46.857886 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/opt/yhmp-app/YHMP/eamena/urls.py", line 19, in <module>
[Wed Dec 16 07:05:46.857889 2020] [wsgi:error] [pid 14047:tid 140483690739456] from arches import urls as arches_urls
[Wed Dec 16 07:05:46.857892 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/opt/yhmp-app/env/lib/python2.7/site-packages/arches/urls.py", line 20, in <module>
[Wed Dec 16 07:05:46.857895 2020] [wsgi:error] [pid 14047:tid 140483690739456] from django.conf.urls import patterns, include, url
[Wed Dec 16 07:05:46.857898 2020] [wsgi:error] [pid 14047:tid 140483690739456] ImportError: cannot import name patterns
[Wed Dec 16 07:05:46.928281 2020] [wsgi:error] [pid 14047:tid 140483690739456] Internal Server Error: /
[Wed Dec 16 07:05:46.928306 2020] [wsgi:error] [pid 14047:tid 140483690739456] Traceback (most recent call last):
[Wed Dec 16 07:05:46.928310 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/core/handlers/base.py", line 131, in get_response
[Wed Dec 16 07:05:46.928313 2020] [wsgi:error] [pid 14047:tid 140483690739456] response = middleware_method(request, response)
[Wed Dec 16 07:05:46.928316 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/middleware/locale.py", line 36, in process_response
[Wed Dec 16 07:05:46.928319 2020] [wsgi:error] [pid 14047:tid 140483690739456] i18n_patterns_used, prefixed_default_language = is_language_prefix_patterns_used(urlconf)
[Wed Dec 16 07:05:46.928323 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/utils/lru_cache.py", line 100, in wrapper
[Wed Dec 16 07:05:46.928326 2020] [wsgi:error] [pid 14047:tid 140483690739456] result = user_function(*args, **kwds)
[Wed Dec 16 07:05:46.928329 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/conf/urls/i18n.py", line 29, in is_language_prefix_patterns_used
[Wed Dec 16 07:05:46.928332 2020] [wsgi:error] [pid 14047:tid 140483690739456] for url_pattern in get_resolver(urlconf).url_patterns:
[Wed Dec 16 07:05:46.928335 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
[Wed Dec 16 07:05:46.928338 2020] [wsgi:error] [pid 14047:tid 140483690739456] res = instance.__dict__[self.name] = self.func(instance)
[Wed Dec 16 07:05:46.928341 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/urls/resolvers.py", line 407, in url_patterns
[Wed Dec 16 07:05:46.928354 2020] [wsgi:error] [pid 14047:tid 140483690739456] patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
[Wed Dec 16 07:05:46.928357 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
[Wed Dec 16 07:05:46.928360 2020] [wsgi:error] [pid 14047:tid 140483690739456] res = instance.__dict__[self.name] = self.func(instance)
[Wed Dec 16 07:05:46.928363 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/urls/resolvers.py", line 400, in urlconf_module
[Wed Dec 16 07:05:46.928366 2020] [wsgi:error] [pid 14047:tid 140483690739456] return import_module(self.urlconf_name)
[Wed Dec 16 07:05:46.928369 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
[Wed Dec 16 07:05:46.928372 2020] [wsgi:error] [pid 14047:tid 140483690739456] __import__(name)
[Wed Dec 16 07:05:46.928375 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/opt/yhmp-app/YHMP/eamena/urls.py", line 19, in <module>
[Wed Dec 16 07:05:46.928378 2020] [wsgi:error] [pid 14047:tid 140483690739456] from arches import urls as arches_urls
[Wed Dec 16 07:05:46.928381 2020] [wsgi:error] [pid 14047:tid 140483690739456] File "/opt/yhmp-app/env/lib/python2.7/site-packages/arches/urls.py", line 20, in <module>
[Wed Dec 16 07:05:46.928384 2020] [wsgi:error] [pid 14047:tid 140483690739456] from django.conf.urls import patterns, include, url
[Wed Dec 16 07:05:46.928387 2020] [wsgi:error] [pid 14047:tid 140483690739456] ImportError: cannot import name patterns
[Wed Dec 16 13:05:47.258838 2020] [authz_core:debug] [pid 14048:tid 140483573556992] mod_authz_core.c(809): [client :56386] AH01626: authorization result of Require all granted: granted, referer: http://database.yhmp.online/
[Wed Dec 16 13:05:47.258876 2020] [authz_core:debug] [pid 14048:tid 140483573556992] mod_authz_core.c(809): [client :56386] AH01626: authorization result of <RequireAny>: granted, referer: http://database.yhmp.online/
[Wed Dec 16 13:05:47.258911 2020] [authz_core:debug] [pid 14048:tid 140483573556992] mod_authz_core.c(809): [client :56386] AH01626: authorization result of Require all granted: granted, referer: http://database.yhmp.online/
[Wed Dec 16 13:05:47.258915 2020] [authz_core:debug] [pid 14048:tid 140483573556992] mod_authz_core.c(809): [client :56386] AH01626: authorization result of <RequireAny>: granted, referer: http://database.yhmp.online/
[Wed Dec 16 07:05:47.259857 2020] [wsgi:error] [pid 14047:tid 140483741136640] Internal Server Error: /favicon.ico
[Wed Dec 16 07:05:47.259871 2020] [wsgi:error] [pid 14047:tid 140483741136640] Traceback (most recent call last):
[Wed Dec 16 07:05:47.259875 2020] [wsgi:error] [pid 14047:tid 140483741136640] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
[Wed Dec 16 07:05:47.259878 2020] [wsgi:error] [pid 14047:tid 140483741136640] response = get_response(request)
[Wed Dec 16 07:05:47.259881 2020] [wsgi:error] [pid 14047:tid 140483741136640] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/core/handlers/base.py", line 244, in _legacy_get_response
[Wed Dec 16 07:05:47.259885 2020] [wsgi:error] [pid 14047:tid 140483741136640] response = middleware_method(request)
[Wed Dec 16 07:05:47.259888 2020] [wsgi:error] [pid 14047:tid 140483741136640] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/middleware/locale.py", line 24, in process_request
[Wed Dec 16 07:05:47.259892 2020] [wsgi:error] [pid 14047:tid 140483741136640] i18n_patterns_used, prefixed_default_language = is_language_prefix_patterns_used(urlconf)
[Wed Dec 16 07:05:47.259895 2020] [wsgi:error] [pid 14047:tid 140483741136640] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/utils/lru_cache.py", line 100, in wrapper
[Wed Dec 16 07:05:47.259909 2020] [wsgi:error] [pid 14047:tid 140483741136640] result = user_function(*args, **kwds)
[Wed Dec 16 07:05:47.259912 2020] [wsgi:error] [pid 14047:tid 140483741136640] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/conf/urls/i18n.py", line 29, in is_language_prefix_patterns_used
[Wed Dec 16 07:05:47.259916 2020] [wsgi:error] [pid 14047:tid 140483741136640] for url_pattern in get_resolver(urlconf).url_patterns:
[Wed Dec 16 07:05:47.259919 2020] [wsgi:error] [pid 14047:tid 140483741136640] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
[Wed Dec 16 07:05:47.259922 2020] [wsgi:error] [pid 14047:tid 140483741136640] res = instance.__dict__[self.name] = self.func(instance)
[Wed Dec 16 07:05:47.259925 2020] [wsgi:error] [pid 14047:tid 140483741136640] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/urls/resolvers.py", line 407, in url_patterns
[Wed Dec 16 07:05:47.259928 2020] [wsgi:error] [pid 14047:tid 140483741136640] patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
[Wed Dec 16 07:05:47.259931 2020] [wsgi:error] [pid 14047:tid 140483741136640] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
[Wed Dec 16 07:05:47.259934 2020] [wsgi:error] [pid 14047:tid 140483741136640] res = instance.__dict__[self.name] = self.func(instance)
[Wed Dec 16 07:05:47.259937 2020] [wsgi:error] [pid 14047:tid 140483741136640] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/urls/resolvers.py", line 400, in urlconf_module
[Wed Dec 16 07:05:47.259940 2020] [wsgi:error] [pid 14047:tid 140483741136640] return import_module(self.urlconf_name)
[Wed Dec 16 07:05:47.259943 2020] [wsgi:error] [pid 14047:tid 140483741136640] File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
[Wed Dec 16 07:05:47.259946 2020] [wsgi:error] [pid 14047:tid 140483741136640] __import__(name)
[Wed Dec 16 07:05:47.259948 2020] [wsgi:error] [pid 14047:tid 140483741136640] File "/opt/yhmp-app/YHMP/eamena/urls.py", line 19, in <module>
[Wed Dec 16 07:05:47.259951 2020] [wsgi:error] [pid 14047:tid 140483741136640] from arches import urls as arches_urls
[Wed Dec 16 07:05:47.259954 2020] [wsgi:error] [pid 14047:tid 140483741136640] File "/opt/yhmp-app/env/lib/python2.7/site-packages/arches/urls.py", line 20, in <module>
[Wed Dec 16 07:05:47.259957 2020] [wsgi:error] [pid 14047:tid 140483741136640] from django.conf.urls import patterns, include, url
[Wed Dec 16 07:05:47.259960 2020] [wsgi:error] [pid 14047:tid 140483741136640] ImportError: cannot import name patterns
[Wed Dec 16 07:05:47.323245 2020] [wsgi:error] [pid 14047:tid 140483741136640] Internal Server Error: /favicon.ico
[Wed Dec 16 07:05:47.323268 2020] [wsgi:error] [pid 14047:tid 140483741136640] Traceback (most recent call last):
[Wed Dec 16 07:05:47.323271 2020] [wsgi:error] [pid 14047:tid 140483741136640] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/core/handlers/base.py", line 131, in get_response
[Wed Dec 16 07:05:47.323275 2020] [wsgi:error] [pid 14047:tid 140483741136640] response = middleware_method(request, response)
[Wed Dec 16 07:05:47.323278 2020] [wsgi:error] [pid 14047:tid 140483741136640] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/middleware/locale.py", line 36, in process_response
[Wed Dec 16 07:05:47.323281 2020] [wsgi:error] [pid 14047:tid 140483741136640] i18n_patterns_used, prefixed_default_language = is_language_prefix_patterns_used(urlconf)
[Wed Dec 16 07:05:47.323284 2020] [wsgi:error] [pid 14047:tid 140483741136640] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/utils/lru_cache.py", line 100, in wrapper
[Wed Dec 16 07:05:47.323287 2020] [wsgi:error] [pid 14047:tid 140483741136640] result = user_function(*args, **kwds)
[Wed Dec 16 07:05:47.323290 2020] [wsgi:error] [pid 14047:tid 140483741136640] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/conf/urls/i18n.py", line 29, in is_language_prefix_patterns_used
[Wed Dec 16 07:05:47.323302 2020] [wsgi:error] [pid 14047:tid 140483741136640] for url_pattern in get_resolver(urlconf).url_patterns:
[Wed Dec 16 07:05:47.323306 2020] [wsgi:error] [pid 14047:tid 140483741136640] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
[Wed Dec 16 07:05:47.323309 2020] [wsgi:error] [pid 14047:tid 140483741136640] res = instance.__dict__[self.name] = self.func(instance)
[Wed Dec 16 07:05:47.323312 2020] [wsgi:error] [pid 14047:tid 140483741136640] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/urls/resolvers.py", line 407, in url_patterns
[Wed Dec 16 07:05:47.323315 2020] [wsgi:error] [pid 14047:tid 140483741136640] patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module)
[Wed Dec 16 07:05:47.323318 2020] [wsgi:error] [pid 14047:tid 140483741136640] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/utils/functional.py", line 35, in __get__
[Wed Dec 16 07:05:47.323321 2020] [wsgi:error] [pid 14047:tid 140483741136640] res = instance.__dict__[self.name] = self.func(instance)
[Wed Dec 16 07:05:47.323324 2020] [wsgi:error] [pid 14047:tid 140483741136640] File "/opt/yhmp-app/env/lib/python2.7/site-packages/django/urls/resolvers.py", line 400, in urlconf_module
[Wed Dec 16 07:05:47.323327 2020] [wsgi:error] [pid 14047:tid 140483741136640] return import_module(self.urlconf_name)
[Wed Dec 16 07:05:47.323329 2020] [wsgi:error] [pid 14047:tid 140483741136640] File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
[Wed Dec 16 07:05:47.323332 2020] [wsgi:error] [pid 14047:tid 140483741136640] __import__(name)
[Wed Dec 16 07:05:47.323335 2020] [wsgi:error] [pid 14047:tid 140483741136640] File "/opt/yhmp-app/YHMP/eamena/urls.py", line 19, in <module>
[Wed Dec 16 07:05:47.323338 2020] [wsgi:error] [pid 14047:tid 140483741136640] from arches import urls as arches_urls
[Wed Dec 16 07:05:47.323341 2020] [wsgi:error] [pid 14047:tid 140483741136640] File "/opt/yhmp-app/env/lib/python2.7/site-packages/arches/urls.py", line 20, in <module>
[Wed Dec 16 07:05:47.323344 2020] [wsgi:error] [pid 14047:tid 140483741136640] from django.conf.urls import patterns, include, url
[Wed Dec 16 07:05:47.323347 2020] [wsgi:error] [pid 14047:tid 140483741136640] ImportError: cannot import name patterns
Sorry for the long log copy and paste, do someone have an idea about what can happened to that? We work within the same server but supposedly anyone touch nothing so it is being very difficult to find where to look for.
in addition this is the file pointed in the Exception Location: /opt/yhmp-app/env/lib/python2.7/site-packages/arches/urls.py
from django.conf import settings
from django.conf.urls import patterns, include, url
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.conf.urls.i18n import patterns
# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
uuid_regex = '[0-9a-fA-F]{8}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{4}-[0-9a-fA-F]{12}'
urlpatterns = patterns('',
url(r'^$', 'arches.app.views.main.index'),
url(r'^index.htm', 'arches.app.views.main.index', name='home'),
url(r'^auth/', 'arches.app.views.main.auth', name='auth'),
url(r'^rdm/(?P<conceptid>%s|())$' % uuid_regex , 'arches.app.views.concept.rdm', name='rdm'),
url(r'^map', 'arches.app.views.map.get_page', name="map"),
url(r'^geocoder', 'arches.app.views.search.geocode', name="geocoder"),
url(r'^entities/(?P<entityid>%s)$' % uuid_regex , 'arches.app.views.entity.Entities'),
url(r'^entityTypes/(?P<entitytypeid>.*)$', 'arches.app.views.entity.EntityTypes'),
url(r'^concepts/(?P<conceptid>%s)/manage_parents/$' % uuid_regex, 'arches.app.views.concept.manage_parents', name="concept_manage_parents"),
url(r'^concepts/(?P<conceptid>%s)/confirm_delete/$' % uuid_regex, 'arches.app.views.concept.confirm_delete', name="confirm_delete"),
url(r'^concepts/(?P<conceptid>%s|())$' % uuid_regex , 'arches.app.views.concept.concept', name="concept"),
url(r'^concepts/tree$', 'arches.app.views.concept.concept_tree', name="concept_tree"),
url(r'^concepts/search$', 'arches.app.views.concept.search', name="concept_search"),
url(r'^concepts/(?P<conceptid>%s)/from_sparql_endpoint$' % uuid_regex, 'arches.app.views.concept.add_concepts_from_sparql_endpoint', name="from_sparql_endpoint"),
url(r'^concepts/search_sparql_endpoint$', 'arches.app.views.concept.search_sparql_endpoint_for_concepts', name="search_sparql_endpoint"),
url(r'^search$', 'arches.app.views.search.home_page', name="search_home"),
url(r'^search/terms$', 'arches.app.views.search.search_terms', name="search_terms"),
url(r'^search/resources$', 'arches.app.views.search.search_results', name="search_results"),
url(r'^buffer/$', 'arches.app.views.search.buffer', name="buffer"),
url(r'^resources/(?P<resourcetypeid>[0-9a-zA-Z_.]*)/(?P<form_id>[a-zA-Z_-]*)/(?P<resourceid>%s|())$' % uuid_regex, 'arches.app.views.resources.resource_manager', name="resource_manager"),
url(r'^resources/related/(?P<resourceid>%s|())$' % uuid_regex, 'arches.app.views.resources.related_resources', name="related_resources"),
url(r'^resources/history/(?P<resourceid>%s|())$' % uuid_regex, 'arches.app.views.resources.edit_history', name="edit_history"),
url(r'^resources/layers/(?P<entitytypeid>.*)$', 'arches.app.views.resources.map_layers', name="map_layers"),
url(r'^resources/markers/(?P<entitytypeid>.*)$', 'arches.app.views.resources.map_layers', {'get_centroids':True}, name="map_markers"),
url(r'^reports/(?P<resourceid>%s)$' % uuid_regex , 'arches.app.views.resources.report', name='report'),
url(r'^get_admin_areas','arches.app.views.resources.get_admin_areas', name='get_admin_areas'),
# Uncomment the admin/doc line below to enable admin documentation:
# url(r'^admin/doc/', include('django.contrib.admindocs.urls')),
# enables language change via form
url(r'^i18n/', include('django.conf.urls.i18n')),
# Uncomment the next line to enable the admin:
url(r'^admin/', include(admin.site.urls)),
)
urlpatterns += staticfiles_urlpatterns()
if settings.DEBUG:
from django.conf.urls.static import static
urlpatterns += static(settings.MEDIA_URL, document_root=settings.MEDIA_ROOT)
After pip freeze in the env mode i get the following details in case they are relevant to solve the issue:
appdirs==1.4.4
arches==3.1.2
arches-hip==1.0.4
configparser==4.0.2
contextlib2==0.6.0.post1
distlib==0.3.1
Django==1.7.11
elasticsearch==1.9.0
filelock==3.0.12
importlib-metadata==2.1.1
importlib-resources==3.3.0
isodate==0.6.0
packaging==20.8
pathlib2==2.3.5
Pillow==2.4.0
pluggy==0.13.1
psycopg2==2.5.4
py==1.10.0
pycryptodome==3.8.1
pyparsing==2.4.0
pyshp==2.1.0
pytz==2020.4
PyYAML==5.1
rdflib==4.2.2
scandir==1.10.0
singledispatch==3.4.0.3
six==1.15.0
SPARQLWrapper==1.8.4
toml==0.10.2
tox==3.20.1
typing==3.7.4.3
unicodecsv==0.14.1
urllib3==1.25.2
virtualenv==20.2.2
xlrd==0.9.0
zipp==1.2.0
Also after change the version of django it appear thsi other error not idea if it is realted:
I would really appreciate your expertise with this and if you can point me in some direction.
Thanks in advance
Was the servers version of django upgraded? patterns was deprecated in 1.10
https://stackoverflow.com/a/38799716/1464664
current implementations looks like this
from django.urls import include, path
urlpatterns = [
path('index/', views.index, name='main-view'),
path('bio/<username>/', views.bio, name='bio'),
path('articles/<slug:title>/', views.article, name='article-detail'),
path('articles/<slug:title>/<int:section>/', views.section, name='article-section'),
path('weblog/', include('blog.urls')),
...
]
*edit
To install an older version of django on the server.
pip install "django==1.10.*"
Collecting django==1.10.*
Downloading https://files.pythonhosted.org/packages/bb/9f/2c20639ac635a83123ddffd91ba15001cb0d04e74fbb08f31fb57e490dab/Django-1.10.8-py2.py3-none-any.whl (6.8MB)
|████████████████████████████████| 6.8MB 17.2MB/s
Installing collected packages: django
ERROR: Could not install packages due to an EnvironmentError: [Errno 13] Permission denied: '/usr/local/lib/python2.7/dist-packages/Django-1.10.8.dist-info'
Consider using the `--user` option or check the permissions.
WARNING: You are using pip version 19.1.1, however version 20.3.1 is available.
You should consider upgrading via the 'pip install --upgrade pip' command.

Open Edx Third Party Login Integration with Keycloak

I am using edx-ironwood.2-6 in ubuntu 18.08. I am also running keycloak 9.0.0. To enable third-party login using Keycloak I am using the python-social-auth library suggested in edx documentation. Since by default keycloak.py was not available in the edx-ironwood, I copied this keycloak.js file at the location
edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_core/backends
Followed all steps written in comments to setup keycloak and added following information in keycloak.py
SECRET = 'client secret'
PUBLIC_KEY = 'publick key from keycloak'
AUTHORIZATION_URL = 'http://localhost:8080/auth/realms/myrealm/protocol/openid-connect/auth'
ACCESS_TOKEN_URL = 'http://localhost:8080/auth/realms/myrealm/protocol/openid-connect/token'
USER_DETAILS_URL = 'http://localhost:8080/auth/realms/myrealm/protocol/openid-connect/userinfo'
Added following line in the lms.env.json
"THIRD_PARTY_AUTH_BACKENDS":[
"social_core.backends.keycloak.KeycloakOAuth2",
"social_core.backends.google.GoogleOAuth2",
"social_core.backends.linkedin.LinkedinOAuth2"
]
In the Django Admin App, Added a Provider
Name: Keycloak
slug: keycloak
site: localhost:81
backend: keycloak
client Id: 'mooc'
Client Secret: 'secret key'
Also Added client secret in lms.auth.json
"SOCIAL_AUTH_OAUTH_SECRETS": {
"keycloak":"14f89ef1-02ff-48ad-825f-8160e515ec8e"
}
In Keycloak client settings, added access type 'confidential', and redirect uri 'http://localhost:81/auth/complete/keycloak/'
After server restart, In edx login page, login button for keycloak appearing but when I am clicking on it in the browser a message is coming There has been a 500 error on the Open Edx Server
In the apache2 log file following error is coming
[Sat Apr 18 17:09:21.212377 2020] [:error] [pid 8143] Traceback (most recent call last):
[Sat Apr 18 17:09:21.212419 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/core/handlers/exception.py", line 41, in inner
[Sat Apr 18 17:09:21.212442 2020] [:error] [pid 8143] response = get_response(request)
[Sat Apr 18 17:09:21.212462 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/core/handlers/base.py", line 249, in _legacy_get_response
[Sat Apr 18 17:09:21.212485 2020] [:error] [pid 8143] response = self._get_response(request)
[Sat Apr 18 17:09:21.212506 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/core/handlers/base.py", line 187, in _get_response
[Sat Apr 18 17:09:21.212526 2020] [:error] [pid 8143] response = self.process_exception_by_middleware(e, request)
[Sat Apr 18 17:09:21.212548 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/core/handlers/base.py", line 185, in _get_response
[Sat Apr 18 17:09:21.212569 2020] [:error] [pid 8143] response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Sat Apr 18 17:09:21.212589 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/utils/decorators.py", line 185, in inner
[Sat Apr 18 17:09:21.212610 2020] [:error] [pid 8143] return func(*args, **kwargs)
[Sat Apr 18 17:09:21.212630 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/views/decorators/cache.py", line 57, in _wrapped_view_func
[Sat Apr 18 17:09:21.212651 2020] [:error] [pid 8143] response = view_func(request, *args, **kwargs)
[Sat Apr 18 17:09:21.212671 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_django/utils.py", line 49, in wrapper
[Sat Apr 18 17:09:21.212697 2020] [:error] [pid 8143] return func(request, backend, *args, **kwargs)
[Sat Apr 18 17:09:21.212720 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_django/views.py", line 23, in auth
[Sat Apr 18 17:09:21.212742 2020] [:error] [pid 8143] return do_auth(request.backend, redirect_name=REDIRECT_FIELD_NAME)
[Sat Apr 18 17:09:21.212762 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_core/actions.py", line 29, in do_auth
[Sat Apr 18 17:09:21.212783 2020] [:error] [pid 8143] return backend.start()
[Sat Apr 18 17:09:21.212803 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_core/backends/base.py", line 35, in start
[Sat Apr 18 17:09:21.212823 2020] [:error] [pid 8143] return self.strategy.redirect(self.auth_url())
[Sat Apr 18 17:09:21.212844 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_django/strategy.py", line 88, in redirect
[Sat Apr 18 17:09:21.212864 2020] [:error] [pid 8143] return redirect(url)
[Sat Apr 18 17:09:21.212884 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/shortcuts.py", line 56, in redirect
[Sat Apr 18 17:09:21.212904 2020] [:error] [pid 8143] return redirect_class(resolve_url(to, *args, **kwargs))
[Sat Apr 18 17:09:21.212925 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/shortcuts.py", line 147, in resolve_url
[Sat Apr 18 17:09:21.212945 2020] [:error] [pid 8143] return reverse(to, args=args, kwargs=kwargs)
[Sat Apr 18 17:09:21.212965 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/src/django-wiki/wiki/models/__init__.py", line 90, in reverse
[Sat Apr 18 17:09:21.212986 2020] [:error] [pid 8143] url = original_django_reverse(*args, **kwargs)
[Sat Apr 18 17:09:21.213006 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/urls/base.py", line 91, in reverse
[Sat Apr 18 17:09:21.213026 2020] [:error] [pid 8143] return force_text(iri_to_uri(resolver._reverse_with_prefix(view, prefix, *args, **kwargs)))
[Sat Apr 18 17:09:21.213047 2020] [:error] [pid 8143] File "/opt/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/django/urls/resolvers.py", line 497, in _reverse_with_prefix
[Sat Apr 18 17:09:21.213067 2020] [:error] [pid 8143] raise NoReverseMatch(msg)
[Sat Apr 18 17:09:21.213089 2020] [:error] [pid 8143] NoReverseMatch: Reverse for 'None?scope=profile+email&state=yst8UI8KZihrluHg9R0oUFexFIx0QYGM&redirect_uri=http%3A%2F%2Flocalhost%3A81%2Fauth%2Fcomplete%2Fkeycloak%2F%3Fredirect_state%3Dyst8UI8KZihrluHg9R0oUFexFIx0QYGM&response_type=code&client_id=mooc' not found. 'None?scope=profile+email&state=yst8UI8KZihrluHg9R0oUFexFIx0QYGM&redirect_uri=http%3A%2F%2Flocalhost%3A81%2Fauth%2Fcomplete%2Fkeycloak%2F%3Fredirect_state%3Dyst8UI8KZihrluHg9R0oUFexFIx0QYGM&response_type=code&client_id=mooc' is not a valid view function or pattern name.
I tried same third party integration with same python-social-auth for LinkedIn and that is working.
Since I am just a beginner in the Django, Can anyone help me identify the issue from the above details.
After finding and reading many official resources, I haven't found any solution which worked. So I decided to try my own custom file for keycloak.
Here is the link of the file
https://github.com/ranjeet692/python-social-auth-keycloak,
For open edx users, place this file into this directory
/edx-ironwood.2-6/apps/edx/venvs/edxapp/lib/python2.7/site-packages/social_core/backends
Follow the rest instruction as mentioned here
Social Auth Documentation
and restart the server. You should be able to login with keycloak.
There is now an official backend for keycloak in python-social-auth:
https://github.com/python-social-auth/social-core/blob/master/social_core/backends/keycloak.py
Just add
"THIRD_PARTY_AUTH_BACKENDS": [
"social_core.backends.keycloak.KeycloakOAuth2"
],
to your lms.env.json
together with the keycloak config:
"SOCIAL_AUTH_KEYCLOAK_KEY": "openedx",
"SOCIAL_AUTH_KEYCLOAK_SECRET": "...",
"SOCIAL_AUTH_KEYCLOAK_PUBLIC_KEY": "...",
"SOCIAL_AUTH_KEYCLOAK_AUTHORIZATION_URL": "https://YOUR_KEYCLOAK/realms/YOUR_REALM/protocol/openid-connect/auth",
"SOCIAL_AUTH_KEYCLOAK_ACCESS_TOKEN_URL": "https://YOUR_KEYCLOAK/realms/YOUR_REALM/protocol/openid-connect/token",
Restart your installation, then go to:
https://YOUR.LMS/admin/third_party_auth/oauth2providerconfig/
and configure according to https://edx.readthedocs.io/projects/edx-installing-configuring-and-running/en/latest/configuration/tpa/tpa_integrate_open/tpa_oauth.html#additional-oauth2-providers-advanced

getting urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetErr or(104, 'Connection reset by peer'))

I have setup a Django project with Apache2 and mod_wsgi on Ubuntu 16.04 instance of AWS. Now I am getting urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetErr or(104, 'Connection reset by peer')) error when I try to access mysite.
I have tried almost everything suggested on stackoverflow and other link. but get no luck.
[Mon Jan 28 21:02:52.263398 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] Traceback (most recent call last):
[Mon Jan 28 21:02:52.263457 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
[Mon Jan 28 21:02:52.263537 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] chunked=chunked)
[Mon Jan 28 21:02:52.263613 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 384, in _make_request
[Mon Jan 28 21:02:52.263655 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] six.raise_from(e, None)
[Mon Jan 28 21:02:52.263707 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "<string>", line 2, in raise_from
[Mon Jan 28 21:02:52.263760 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 380, in _make_request
[Mon Jan 28 21:02:52.263799 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] httplib_response = conn.getresponse()
[Mon Jan 28 21:02:52.263851 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
[Mon Jan 28 21:02:52.263903 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] response.begin()
[Mon Jan 28 21:02:52.263943 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/usr/lib/python3.6/http/client.py", line 297, in begin
[Mon Jan 28 21:02:52.263995 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] version, status, reason = self._read_status()
[Mon Jan 28 21:02:52.264032 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/usr/lib/python3.6/http/client.py", line 258, in _read_status
[Mon Jan 28 21:02:52.264086 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
[Mon Jan 28 21:02:52.264129 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/usr/lib/python3.6/socket.py", line 586, in readinto
[Mon Jan 28 21:02:52.264165 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] return self._sock.recv_into(b)
[Mon Jan 28 21:02:52.264200 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] ConnectionResetError: [Errno 104] Connection reset by peer
[Mon Jan 28 21:02:52.264234 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898]
[Mon Jan 28 21:02:52.264268 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] During handling of the above exception, another exception occurred:
[Mon Jan 28 21:02:52.302940 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898]
[Mon Jan 28 21:02:52.302961 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] Traceback (most recent call last):
[Mon Jan 28 21:02:52.302991 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/django/core/handlers/except ion.py", line 34, in inner
[Mon Jan 28 21:02:52.302994 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] response = get_response(request)
[Mon Jan 28 21:02:52.302996 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/django/core/handlers/base.p y", line 126, in _get_response
[Mon Jan 28 21:02:52.302999 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] response = self.process_exception_by_middleware(e, request)
[Mon Jan 28 21:02:52.303001 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/django/core/handlers/base.p y", line 124, in _get_response
[Mon Jan 28 21:02:52.303004 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Mon Jan 28 21:02:52.303006 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/django/views/decorators/csr f.py", line 54, in wrapped_view
[Mon Jan 28 21:02:52.303009 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] return view_func(*args, **kwargs)
[Mon Jan 28 21:02:52.303011 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/home/jshree/Dscrapper/soqqlesocial/data_scrapper/views.py", line 63 , in request_page
[Mon Jan 28 21:02:52.303014 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] twitter.scrap_tweets(rDate, rDatePre, uName, lName)
[Mon Jan 28 21:02:52.303017 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/home/jshree/Dscrapper/soqqlesocial/twitter.py", line 48, in scrap_t weets
[Mon Jan 28 21:02:52.303019 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] drw = webdriver.Chrome(executable_path='/usr/bin/chromedriver', options= options)
[Mon Jan 28 21:02:52.303021 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/selenium/webdriver/chrome/w ebdriver.py", line 81, in __init__
[Mon Jan 28 21:02:52.303024 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] desired_capabilities=desired_capabilities)
[Mon Jan 28 21:02:52.303026 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/selenium/webdriver/remote/w ebdriver.py", line 157, in __init__
[Mon Jan 28 21:02:52.303029 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] self.start_session(capabilities, browser_profile)
[Mon Jan 28 21:02:52.303031 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/selenium/webdriver/remote/w ebdriver.py", line 252, in start_session
[Mon Jan 28 21:02:52.303034 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] response = self.execute(Command.NEW_SESSION, parameters)
[Mon Jan 28 21:02:52.303036 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/selenium/webdriver/remote/w ebdriver.py", line 319, in execute
[Mon Jan 28 21:02:52.303038 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] response = self.command_executor.execute(driver_command, params)
[Mon Jan 28 21:02:52.303041 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/selenium/webdriver/remote/r emote_connection.py", line 374, in execute
[Mon Jan 28 21:02:52.303043 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] return self._request(command_info[0], url, body=data)
[Mon Jan 28 21:02:52.303048 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/selenium/webdriver/remote/r emote_connection.py", line 397, in _request
[Mon Jan 28 21:02:52.303051 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] resp = self._conn.request(method, url, body=body, headers=headers)
[Mon Jan 28 21:02:52.303053 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/request.py", line 7 2, in request
[Mon Jan 28 21:02:52.303056 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] **urlopen_kw)
[Mon Jan 28 21:02:52.303058 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/request.py", line 1 50, in request_encode_body
[Mon Jan 28 21:02:52.303060 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] return self.urlopen(method, url, **extra_kw)
[Mon Jan 28 21:02:52.303063 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/poolmanager.py", li ne 323, in urlopen
[Mon Jan 28 21:02:52.303065 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] response = conn.urlopen(method, u.request_uri, **kw)
[Mon Jan 28 21:02:52.303067 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 638, in urlopen
[Mon Jan 28 21:02:52.303070 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] _stacktrace=sys.exc_info()[2])
[Mon Jan 28 21:02:52.303072 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/util/retry.py", lin e 367, in increment
[Mon Jan 28 21:02:52.303075 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] raise six.reraise(type(error), error, _stacktrace)
[Mon Jan 28 21:02:52.303077 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/packages/six.py", l ine 685, in reraise
[Mon Jan 28 21:02:52.303079 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] raise value.with_traceback(tb)
[Mon Jan 28 21:02:52.303082 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 600, in urlopen
[Mon Jan 28 21:02:52.303084 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] chunked=chunked)
[Mon Jan 28 21:02:52.303086 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 384, in _make_request
[Mon Jan 28 21:02:52.303089 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] six.raise_from(e, None)
[Mon Jan 28 21:02:52.303091 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "<string>", line 2, in raise_from
[Mon Jan 28 21:02:52.303093 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/var/www/env/lib/python3.6/site-packages/urllib3/connectionpool.py", line 380, in _make_request
[Mon Jan 28 21:02:52.303096 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] httplib_response = conn.getresponse()
[Mon Jan 28 21:02:52.303098 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/usr/lib/python3.6/http/client.py", line 1331, in getresponse
[Mon Jan 28 21:02:52.303100 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] response.begin()
[Mon Jan 28 21:02:52.303105 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/usr/lib/python3.6/http/client.py", line 297, in begin
[Mon Jan 28 21:02:52.303107 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] version, status, reason = self._read_status()
[Mon Jan 28 21:02:52.303110 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/usr/lib/python3.6/http/client.py", line 258, in _read_status
[Mon Jan 28 21:02:52.303112 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] line = str(self.fp.readline(_MAXLINE + 1), "iso-8859-1")
[Mon Jan 28 21:02:52.303114 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] File "/usr/lib/python3.6/socket.py", line 586, in readinto
[Mon Jan 28 21:02:52.303117 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] return self._sock.recv_into(b)
[Mon Jan 28 21:02:52.303124 2019] [wsgi:error] [pid 27292:tid 140652916205312] [remote 172.31.25.223:61898] urllib3.exceptions.ProtocolError: ('Connection aborted.', ConnectionResetErr or(104, 'Connection reset by peer'))
update
I have used request-timeout flag in apache conf file by which I have got rid of this error but still getting 504 Gateway Time-out error page after a some time of wait. Any idea to get rid of this or handle it.

504 Gateway Timeout sending mail

I have a problem sending mail from a contact form with Django. I have set smtp config in settings.py and I can send it from local. But in production server, I get a 504 Gateway Timeout Error. This is the Error Log content.
[Sun Jul 17 18:17:46.142782 2016] [wsgi:error] [pid 16049] [client XXXXX:37298] Timeout when reading response headers from daemon process 'domain.gal': /home/wsgi/web/domain.gal/private/django/domain.gal/domain/wsgi.py, referer: http://domain.gal/contacto/
[Sun Jul 17 18:17:49.120971 2016] [wsgi:error] [pid 16046] Internal Server Error: /contacto/
[Sun Jul 17 18:17:49.121004 2016] [wsgi:error] [pid 16046] Traceback (most recent call last):
[Sun Jul 17 18:17:49.121008 2016] [wsgi:error] [pid 16046] File "/home/wsgi/web/domain.gal/private/django/env/lib/python3.4/site-packages/django/core/handlers/base.py", line 149, in get_response
[Sun Jul 17 18:17:49.121012 2016] [wsgi:error] [pid 16046] response = self.process_exception_by_middleware(e, request)
[Sun Jul 17 18:17:49.121015 2016] [wsgi:error] [pid 16046] File "/home/wsgi/web/domain.gal/private/django/env/lib/python3.4/site-packages/django/core/handlers/base.py", line 147, in get_response
[Sun Jul 17 18:17:49.121018 2016] [wsgi:error] [pid 16046] response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Sun Jul 17 18:17:49.121021 2016] [wsgi:error] [pid 16046] File "/home/wsgi/web/domain.gal/private/django/domain.gal/home/views.py", line 43, in contacto
[Sun Jul 17 18:17:49.121023 2016] [wsgi:error] [pid 16046] send_mail(subject, message, from_email, ['info#domain.es'])
[Sun Jul 17 18:17:49.121026 2016] [wsgi:error] [pid 16046] File "/home/wsgi/web/domain.gal/private/django/env/lib/python3.4/site-packages/django/core/mail/__init__.py", line 61, in send_mail
[Sun Jul 17 18:17:49.121029 2016] [wsgi:error] [pid 16046] return mail.send()
[Sun Jul 17 18:17:49.121032 2016] [wsgi:error] [pid 16046] File "/home/wsgi/web/domain.gal/private/django/env/lib/python3.4/site-packages/django/core/mail/message.py", line 292, in send
[Sun Jul 17 18:17:49.121034 2016] [wsgi:error] [pid 16046] return self.get_connection(fail_silently).send_messages([self])
[Sun Jul 17 18:17:49.121037 2016] [wsgi:error] [pid 16046] File "/home/wsgi/web/domain.gal/private/django/env/lib/python3.4/site-packages/django/core/mail/backends/smtp.py", line 100, in send_messages
[Sun Jul 17 18:17:49.121040 2016] [wsgi:error] [pid 16046] new_conn_created = self.open()
[Sun Jul 17 18:17:49.121043 2016] [wsgi:error] [pid 16046] File "/home/wsgi/web/domain.gal/private/django/env/lib/python3.4/site-packages/django/core/mail/backends/smtp.py", line 58, in open
[Sun Jul 17 18:17:49.121060 2016] [wsgi:error] [pid 16046] self.connection = connection_class(self.host, self.port, **connection_params)
[Sun Jul 17 18:17:49.121063 2016] [wsgi:error] [pid 16046] File "/usr/lib64/python3.4/smtplib.py", line 242, in __init__
[Sun Jul 17 18:17:49.121066 2016] [wsgi:error] [pid 16046] (code, msg) = self.connect(host, port)
[Sun Jul 17 18:17:49.121069 2016] [wsgi:error] [pid 16046] File "/usr/lib64/python3.4/smtplib.py", line 321, in connect
[Sun Jul 17 18:17:49.121071 2016] [wsgi:error] [pid 16046] self.sock = self._get_socket(host, port, self.timeout)
[Sun Jul 17 18:17:49.121074 2016] [wsgi:error] [pid 16046] File "/usr/lib64/python3.4/smtplib.py", line 292, in _get_socket
[Sun Jul 17 18:17:49.121076 2016] [wsgi:error] [pid 16046] self.source_address)
[Sun Jul 17 18:17:49.121079 2016] [wsgi:error] [pid 16046] File "/usr/lib64/python3.4/socket.py", line 512, in create_connection
[Sun Jul 17 18:17:49.121081 2016] [wsgi:error] [pid 16046] raise err
[Sun Jul 17 18:17:49.121084 2016] [wsgi:error] [pid 16046] File "/usr/lib64/python3.4/socket.py", line 503, in create_connection
[Sun Jul 17 18:17:49.121086 2016] [wsgi:error] [pid 16046] sock.connect(sa)
[Sun Jul 17 18:17:49.121091 2016] [wsgi:error] [pid 16046] TimeoutError: [Errno 110] Connection timed out
[Sun Jul 17 18:17:49.121097 2016] [wsgi:error] [pid 16046]
Any idea plz?
Your app can't connect to the specified SMTP server. Check for the following issues:
Is your SMTP details correct?
Do you have a running SMTP server at the configured host/port?
Is the connection being blocked by a firewall?
From the log, it's evident that the SMTP connection is timing out. Please provide more details (code/configuration) to speculate better.
Ok masnum is right. I have changed the port and dissabled TLS use and it works. But I have two questions. My configuration was the follow:
EMAIL_PORT = 587
EMAIL_USE_TLS = True
Is this correct? I can use this in localhost, why not in production server? Busy port maybe?
And the other question. I use this:
try:
send_mail(subject, message, from_email, ['info#domain.com'])
except BadHeaderError:
messages.warning(request, 'Ha ocurrido un fallo. Inténtelo de nuevo más tarde.')
return render(request, "contacto.html", {'form': form})
except TimeoutError:
messages.warning(request, 'Ha ocurrido un fallo. Inténtelo de nuevo más tarde.')
return render(request, "contacto.html", {'form': form})
Why the error is not catched by TimeoutError instead of 504 Apache?
Txh

Apache misconfiguring httpd.conf

I uploaded the httpd.conf file for the staging django server to the live server and restarted it and that brought the site down. After returning the right file restarting it and stopping staging server I get internal server error roughly once for every 5 refreshes on the page that shows missing info for top_menu
[Fri Nov 13 11:38:41.793432 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] result = block.nodelist.render(context)
[Fri Nov 13 11:38:41.793440 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] File "/home/kbuzz/lib/python2.7/django/template/base.py", line 844, in render
[Fri Nov 13 11:38:41.793452 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] bit = self.render_node(node, context)
[Fri Nov 13 11:38:41.793461 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] File "/home/kbuzz/lib/python2.7/django/template/base.py", line 858, in render_node
[Fri Nov 13 11:38:41.793473 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] return node.render(context)
[Fri Nov 13 11:38:41.793481 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] File "/home/kbuzz/webapps/django/lib/python2.7/mptt/templatetags/mptt_tags.py", line 284, in render
[Fri Nov 13 11:38:41.793495 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] queryset = self.queryset_var.resolve(context)
[Fri Nov 13 11:38:41.793504 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] File "/home/kbuzz/lib/python2.7/django/template/base.py", line 734, in resolve
[Fri Nov 13 11:38:41.793516 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] value = self._resolve_lookup(context)
[Fri Nov 13 11:38:41.793524 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] File "/home/kbuzz/lib/python2.7/django/template/base.py", line 780, in _resolve_lookup
[Fri Nov 13 11:38:41.793537 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] (bit, current)) # missing attribute
[Fri Nov 13 11:38:41.793580 2015] [wsgi:error] [pid 130327:tid 139718655588096] [remote 127.0.0.1:25256] VariableDoesNotExist: Failed lookup for key [top_menu] in u"[{'False': False, 'None': None, 'True': True}, {}]"
which goes to this context proccessor 'top_menu':Page.objects.filter(top_menu=True, visible=True), and returns the info correctly when I run it from the shell.
>>> from pages.models import *
>>> Page.objects.filter(top_menu=True, visible=True)
[<Page: Home>, <Page: What’s On>, <Page: What’s On :: Today>, <Page: What’s On :
: This Weekend>, <Page: What’s On :: This Month>, <Page: Movies>, <Page: Movies
:: Now Showing>, <Page: Lifestyle>, <Page: Biz Directory>, <Page: Buy&Sell >, <P
age: Galleries>, <Page: Newsletters>]
>>>
I want to reset the apache server to start working correctly now.
I found the error was with the sys path in the wsgi it was pointing to the wrong path and restarting the server made the error to start coming.