It is the same thread as this question.
The problem is that the output values on the local and EB instances are different.
users/views.py
class UsersViewSet(ModelViewSet):
queryset = User.objects.all()
serializer_class = UserSerializer
def get_permissions(self):
if self.action == "list":
permission_classes = [IsAdminUser]
elif self.action == "create" or self.action == "retrieve":
permission_classes = [AllowAny]
elif self.action == "destroy":
permission_classes = [IsAdminOrSelf]
else:
permission_classes = [IsSelf]
return [permission() for permission in permission_classes]
users/permissions.py
class IsAdminUser(BasePermission):
"""
Allows access only to admin users.
"""
def has_permission(self, request, view):
print("=" * 50)
print(dir(request))
print(request.authenticators)
print(request.auth)
print(request.data)
print(request.user)
print("=" * 50)
return bool(request.user and request.user.is_admin)
The main code is as above, and the result of sending GET user list request to the server is as follows.
EB
[Wed Jul 01 21:58:26.498909 2020] [:error] [pid
8264] ========================================
==========
[Wed Jul 01 21:58:26.499000 2020] [:error] [pid 8264] ['DATA', 'FILES', 'POST', 'QUERY_PARAMS', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_auth', '_authenticate', '_authenticator', '_content_type', '_data', '_default_negotiator', '_files', '_full_data', '_load_data_and_files', '_load_stream', '_not_authenticated', '_parse', '_request', '_stream', '_supports_form_parsing', '_user', 'accepted_media_type', 'accepted_renderer', 'auth', 'authenticators', 'content_type', 'data', 'force_plaintext_errors', 'negotiator', 'parser_context', 'parsers', 'query_params', 'stream', 'successful_authenticator', 'user', 'version', 'versioning_scheme']
[Wed Jul 01 21:58:26.499016 2020] [:error] [pid 8264] [<rest_framework_simplejwt.authentication.JWTAuthentication object at 0x7fa4e7c578d0>]
[Wed Jul 01 21:58:26.499024 2020] [:error] [pid 8264] None
[Wed Jul 01 21:58:26.499472 2020] [:error] [pid 8264] <QueryDict: {}>
[Wed Jul 01 21:58:26.499487 2020] [:error] [pid 8264] AnonymousUser
[Wed Jul 01 21:58:26.499493 2020] [:error] [pid 8264] ==================================================
Local
==================================================
['DATA', 'FILES', 'POST', 'QUERY_PARAMS', '__class__', '__delattr__', '__dict__', '__dir__', '__doc__', '__eq__', '__format__', '__ge__', '__getattr__', '__getattribute__', '__gt__', '__hash__', '__init__', '__init_subclass__', '__le__', '__lt__', '__module__', '__ne__', '__new__', '__reduce__', '__reduce_ex__', '__repr__', '__setattr__', '__sizeof__', '__str__', '__subclasshook__', '__weakref__', '_auth', '_authenticate', '_authenticator', '_content_type', '_data', '_default_negotiator', '_files', '_full_data', '_load_data_and_files', '_load_stream', '_not_authenticated', '_parse', '_request', '_stream', '_supports_form_parsing', '_user', 'accepted_media_type', 'accepted_renderer', 'auth', 'authenticators', 'content_type', 'data', 'force_plaintext_errors', 'negotiator', 'parser_context', 'parsers', 'query_params', 'stream', 'successful_authenticator', 'user', 'version', 'versioning_scheme']
[<rest_framework_simplejwt.authentication.JWTAuthentication object at 0x7f8cb8688e10>]
eyJ0eXAiOiJKV1QiLCJhbGciOiJIUzI1NiJ9.eyJ0b2tlbl90eXBlIjoiYWNjZXNzIiwiZXhwIjoxNTkzNjI2MDk4LCJqdGkiOiI3ZWNmMGZkZDJlMjk0MzRjOWExYmRhNWM0ZDY3NWQwOSIsInVzZXJfaWQiOjF9.AqPthXqfErjhT9rnknRzRIhvU5eAG8k0SsnaPLgTlSc
<QueryDict: {}>
1 : tim - tim#mole.land
==================================================
[01/Jul/2020 21:56:30] "GET /api/v1/users/ HTTP/1.1" 200 1768
Why doesn't the EB instance receive the value of the Authorization header?
Related
I follow this tutorial https://www.codementor.io/#jqn/deploy-a-flask-app-on-aws-ec2-13hp1ilqy2 to setup Flask in EC2. Everything works well up to Step 3 (where index.html from flask folder is served).
But as soon as I move to Step 4 (to enable Flask Python app, and link it to Apache), I got the below error.
Any suggestions? Thank you in advance
[Thu Jan 07 01:36:14.607338 2021] [wsgi:error] [pid 1387:tid 140388356159232] [client 119.74.148.227:30755] mod_wsgi (pid=1387): Exception occurred processing WSGI script '/var/www/html/flaskapp/flaskapp.wsgi'.
[Thu Jan 07 01:36:14.607434 2021] [wsgi:error] [pid 1387:tid 140388356159232] [client 119.74.148.227:30755] Traceback (most recent call last):
[Thu Jan 07 01:36:14.607522 2021] [wsgi:error] [pid 1387:tid 140388356159232] [client 119.74.148.227:30755] File "/var/www/html/flaskapp/flaskapp.wsgi", line 5, in <module>
[Thu Jan 07 01:36:14.607622 2021] [wsgi:error] [pid 1387:tid 140388356159232] [client 119.74.148.227:30755] from flaskapp import app as application
[Thu Jan 07 01:36:14.607708 2021] [wsgi:error] [pid 1387:tid 140388356159232] [client 119.74.148.227:30755] ImportError: No module named flaskapp
I forgot to create flaskapp.py as mentioned in the tutorial link. My bad!
from flask import Flask
app = Flask(__name__)
#app.route('/')
def hello_world():
return 'Hello from Flask!'
if __name__ == '__main__':
app.run()
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.
I am uploading a website to a Ubuntu 14.04 VPS for the first time. I am using Apache 2.4.7, mod_wsgi, and Django 1.8.5. I am getting a 500 Internal Server Error. I cannot figure out if the problem is in my wsgi file or configuration or my Django configuration.
Apache Error Log:
[Tue Dec 15 19:57:14.734974 2015] [mpm_event:notice] [pid 28996:tid 139939323643776] AH00491: caught SIGTERM, shutting down
[Tue Dec 15 19:57:15.751172 2015] [mpm_event:notice] [pid 29181:tid 139688285566848] AH00489: Apache/2.4.7 (Ubuntu) mod_wsgi/3.4 Python/2.7.6 configured -- resuming normal operations
[Tue Dec 15 19:57:15.751270 2015] [core:notice] [pid 29181:tid 139688285566848] AH00094: Command line: '/usr/sbin/apache2'
[Tue Dec 15 19:57:19.996550 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] mod_wsgi (pid=29185): Exception occurred processing WSGI script '/var/www/MYSITE/MYSITE/wsgi.py'.
[Tue Dec 15 19:57:19.996694 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] Traceback (most recent call last):
[Tue Dec 15 19:57:19.996935 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__
[Tue Dec 15 19:57:19.997146 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] self.load_middleware()
[Tue Dec 15 19:57:19.997163 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 45, in load_middleware
[Tue Dec 15 19:57:19.997291 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] mw_class = import_by_path(middleware_path)
[Tue Dec 15 19:57:19.997305 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] File "/usr/lib/python2.7/dist-packages/django/utils/module_loading.py", line 26, in import_by_path
[Tue Dec 15 19:57:19.997361 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] sys.exc_info()[2])
[Tue Dec 15 19:57:19.997371 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] File "/usr/lib/python2.7/dist-packages/django/utils/module_loading.py", line 21, in import_by_path
[Tue Dec 15 19:57:19.997384 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] module = import_module(module_path)
[Tue Dec 15 19:57:19.997389 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] File "/usr/lib/python2.7/dist-packages/django/utils/importlib.py", line 40, in import_module
[Tue Dec 15 19:57:19.997425 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] __import__(name)
[Tue Dec 15 19:57:19.997447 2015] [:error] [pid 29185:tid 139688073475840] [client 107.143.109.119:50975] ImproperlyConfigured: Error importing module django.middleware.security: "No module named security"
[Tue Dec 15 19:57:20.201372 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] mod_wsgi (pid=29184): Exception occurred processing WSGI script '/var/www/MYSITE/MYSITE/wsgi.py'., referer: http://MY_IP/
[Tue Dec 15 19:57:20.201446 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] Traceback (most recent call last):, referer: http://MY_IP/
[Tue Dec 15 19:57:20.201468 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__, referer: http://MY_IP/
[Tue Dec 15 19:57:20.201575 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] self.load_middleware(), referer: http://MY_IP/
[Tue Dec 15 19:57:20.201587 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 45, in load_middleware, referer: http://MY_IP/
[Tue Dec 15 19:57:20.201699 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] mw_class = import_by_path(middleware_path), referer: http://MY_IP/
[Tue Dec 15 19:57:20.201713 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] File "/usr/lib/python2.7/dist-packages/django/utils/module_loading.py", line 26, in import_by_path, referer: http://MY_IP/
[Tue Dec 15 19:57:20.201765 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] sys.exc_info()[2]), referer: http://MY_IP/
[Tue Dec 15 19:57:20.201775 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] File "/usr/lib/python2.7/dist-packages/django/utils/module_loading.py", line 21, in import_by_path, referer: http://MY_IP/
[Tue Dec 15 19:57:20.201798 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] module = import_module(module_path), referer: http://MY_IP/
[Tue Dec 15 19:57:20.201806 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] File "/usr/lib/python2.7/dist-packages/django/utils/importlib.py", line 40, in import_module, referer: http://MY_IP/
[Tue Dec 15 19:57:20.201845 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] __import__(name), referer: http://MY_IP/
[Tue Dec 15 19:57:20.201869 2015] [:error] [pid 29184:tid 139688190367488] [client 107.143.109.119:50976] ImproperlyConfigured: Error importing module django.middleware.security: "No module named security", referer: http://MY_IP/
[Tue Dec 15 19:57:22.650853 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] mod_wsgi (pid=29184): Exception occurred processing WSGI script '/var/www/MYSITE/MYSITE/wsgi.py'.
[Tue Dec 15 19:57:22.650936 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] Traceback (most recent call last):
[Tue Dec 15 19:57:22.650987 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__
[Tue Dec 15 19:57:22.651044 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] self.load_middleware()
[Tue Dec 15 19:57:22.651062 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 45, in load_middleware
[Tue Dec 15 19:57:22.651083 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] mw_class = import_by_path(middleware_path)
[Tue Dec 15 19:57:22.651094 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] File "/usr/lib/python2.7/dist-packages/django/utils/module_loading.py", line 26, in import_by_path
[Tue Dec 15 19:57:22.651111 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] sys.exc_info()[2])
[Tue Dec 15 19:57:22.651119 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] File "/usr/lib/python2.7/dist-packages/django/utils/module_loading.py", line 21, in import_by_path
[Tue Dec 15 19:57:22.651131 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] module = import_module(module_path)
[Tue Dec 15 19:57:22.651140 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] File "/usr/lib/python2.7/dist-packages/django/utils/importlib.py", line 40, in import_module
[Tue Dec 15 19:57:22.651154 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] __import__(name)
[Tue Dec 15 19:57:22.651184 2015] [:error] [pid 29184:tid 139688107046656] [client 107.143.109.119:50978] ImproperlyConfigured: Error importing module django.middleware.security: "No module named security"
[Tue Dec 15 19:57:22.719625 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] mod_wsgi (pid=29184): Exception occurred processing WSGI script '/var/www/MYSITE/MYSITE/wsgi.py'., referer: http://MY_IP/
[Tue Dec 15 19:57:22.719704 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] Traceback (most recent call last):, referer: http://MY_IP/
[Tue Dec 15 19:57:22.719756 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] File "/usr/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__, referer: http://MY_IP/
[Tue Dec 15 19:57:22.719834 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] self.load_middleware(), referer: http://MY_IP/
[Tue Dec 15 19:57:22.719855 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] File "/usr/lib/python2.7/dist-packages/django/core/handlers/base.py", line 45, in load_middleware, referer: http://MY_IP/
[Tue Dec 15 19:57:22.719878 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] mw_class = import_by_path(middleware_path), referer: http://MY_IP/
[Tue Dec 15 19:57:22.719890 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] File "/usr/lib/python2.7/dist-packages/django/utils/module_loading.py", line 26, in import_by_path, referer: http://MY_IP/
[Tue Dec 15 19:57:22.719911 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] sys.exc_info()[2]), referer: http://MY_IP/
[Tue Dec 15 19:57:22.719921 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] File "/usr/lib/python2.7/dist-packages/django/utils/module_loading.py", line 21, in import_by_path, referer: http://MY_IP/
[Tue Dec 15 19:57:22.719958 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] module = import_module(module_path), referer: http://MY_IP/
[Tue Dec 15 19:57:22.719971 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] File "/usr/lib/python2.7/dist-packages/django/utils/importlib.py", line 40, in import_module, referer: http://MY_IP/
[Tue Dec 15 19:57:22.719989 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] __import__(name), referer: http://MY_IP/
[Tue Dec 15 19:57:22.720022 2015] [:error] [pid 29184:tid 139688098653952] [client 107.143.109.119:50977] ImproperlyConfigured: Error importing module django.middleware.security: "No module named security", referer: http://MY_IP/
wsgi.py:
import os, sys
sys.path.append('/var/www/MYSITE')
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "MYSITE.settings")
application = get_wsgi_application()
Apache Virtual Host:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port t$
# the server uses to identify itself. This is used when creating
# redirection URLs. In the context of virtual hosts, the ServerName
# specifies what hostname must appear in the request's Host: header to
# match this virtual host. For the default virtual host (this file) this
# value is not decisive as it is used as a last resort host regardless.
# However, you must set it for any further virtual host explicitly.
ServerName MYSITEinc.com
ServerAlias www.MYSITEinc.com
ServerAdmin email#site.com
DocumentRoot /var/www/MYSITE
WSGIScriptAlias / /var/www/MYSITE/MYSITE/wsgi.py
<Directory /var/www/MYSITE/MYSITE>
Require all granted
</Directory>
Alias /static /var/www/MYSITE/static
<Directory /var/www/MYSITE/static>
Require all granted
</Directory>
# Available loglevels: trace8, ..., trace1, debug, info, notice, warn,
# error, crit, alert, emerg.
# It is also possible to configure the loglevel for particular
# modules, e.g.
#LogLevel info ssl:warn
ErrorLog ${APACHE_LOG_DIR}/error.log
CustomLog ${APACHE_LOG_DIR}/access.log combined
# For most configuration files from conf-available/, which are
# enabled or disabled at a global level, it is possible to
# include a line for only one particular virtual host. For example the
# following line enables the CGI configuration for this host only
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
# vim: syntax=apache ts=4 sw=4 sts=4 sr noet
settings.py
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
SECRET_KEY = ‘KEY’
DEBUG = False
CSRF_COOKIE_SECURE = False
SESSION_COOKIE_SECURE = False
ADMINS = ((‘Name’), ‘name#site.com’)
MANAGERS = ((‘Name’), ‘name#site.com’)
ALLOWED_HOSTS = [
‘IP_ADDRESS’, ‘MYSITE.com',
]
INSTALLED_APPS = (
'django_admin_bootstrapped',
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
'web',
'bootstrap3',
'feedparser',
)
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 = ‘MYSITE.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': [os.path.join(BASE_DIR, 'templates')],
'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',
'django.core.context_processors.static',
],
},
},
]
WSGI_APPLICATION = 'MYSITE.wsgi.application'
AUTH_USER_MODEL = 'web.User'
LOGIN_URL = '/login/'
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'MYSITE',
'USER': 'root',
'PASSWORD': ‘PASSWORD’,
'HOST': ‘IP_ADDRESS’,
'PORT': '3306',
}
}
CONN_MAX_AGE = None
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
STATIC_URL = '/static/'
STATIC_ROOT = '/Users/MYNAME/MYSITE/'
EMAIL_USE_TLS = True
EMAIL_HOST = 'smtp.gmail.com'
EMAIL_PORT = 587
EMAIL_HOST_USER = 'MYSITE#gmail.com'
EMAIL_HOST_PASSWORD = ‘PASSWORD’
If anyone has suggestions or solutions, can you please post them?
I believe you have your middleware in the wrong order.
Try putting your session middleware BEFORE your auth middleware (error in your logs indicates this problem).
The Django documentation covers middleware ordering as well.
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.
I am trying to deploy django website.Project name is pom.
I am trying to run django website in ec2 server using apache2 and getting the following error:
Apache error file:
[Fri Jul 24 12:37:33.621285 2015] [:info] [pid 20446:tid 140024755709824] mod_wsgi (pid=20446): Attach interpreter ''.
[Fri Jul 24 12:37:33.621462 2015] [:info] [pid 20446:tid 140024755709824] mod_wsgi (pid=20446): Adding '/home/ubuntu/.virtualenvs/edusamosa/lib/python2.7/site-packages/' to path.
[Fri Jul 24 12:37:44.145762 2015] [authz_core:debug] [pid 20448:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11934] AH01626: authorization result of Require all granted: granted
[Fri Jul 24 12:37:44.145888 2015] [authz_core:debug] [pid 20448:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11934] AH01626: authorization result of <RequireAny>: granted
[Fri Jul 24 12:37:44.145947 2015] [authz_core:debug] [pid 20448:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11934] AH01626: authorization result of Require all granted: granted
[Fri Jul 24 12:37:44.145953 2015] [authz_core:debug] [pid 20448:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11934] AH01626: authorization result of <RequireAny>: granted
[Fri Jul 24 12:37:44.152795 2015] [:info] [pid 20446:tid 140024564070144] mod_wsgi (pid=20446): Create interpreter 'www.edusamosa.in|'.
[Fri Jul 24 12:37:44.153592 2015] [:info] [pid 20446:tid 140024564070144] mod_wsgi (pid=20446): Adding '/home/ubuntu/.virtualenvs/edusamosa/lib/python2.7/site-packages/' to path.
[Fri Jul 24 12:37:44.152795 2015] [:info] [pid 20446:tid 140024564070144] mod_wsgi (pid=20446): Create interpreter 'www.edusamosa.in|'.
[Fri Jul 24 12:37:44.153592 2015] [:info] [pid 20446:tid 140024564070144] mod_wsgi (pid=20446): Adding '/home/ubuntu/.virtualenvs/edusamosa/lib/python2.7/site-packages/' to path.
[Fri Jul 24 12:37:44.153884 2015] [:info] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] mod_wsgi (pid=20446, process='pom', application='www.edusamosa.in|'): Loading WSGI script '/home/ubuntu/pom/pom/wsgi.py'.
[Fri Jul 24 12:37:44.354165 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] mod_wsgi (pid=20446): Target WSGI script '/home/ubuntu/pom/pom/wsgi.py' cannot be loaded as Python module.
[Fri Jul 24 12:37:44.354189 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] mod_wsgi (pid=20446): Exception occurred processing WSGI script '/home/ubuntu/pom/pom/wsgi.py'.
[Fri Jul 24 12:37:44.354222 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] Traceback (most recent call last):
[Fri Jul 24 12:37:44.354238 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] File "/home/ubuntu/pom/pom/wsgi.py", line 19, in <module>
[Fri Jul 24 12:37:44.354362 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] application = get_wsgi_application()
# [Fri Jul 24 12:37:44.354238 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] File "/home/ubuntu/pom/pom/wsgi.py", line 19, in <module>
[Fri Jul 24 12:37:44.354362 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] application = get_wsgi_application()
[Fri Jul 24 12:37:44.354377 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Fri Jul 24 12:37:44.354416 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] django.setup()
[Fri Jul 24 12:37:44.354428 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
[Fri Jul 24 12:37:44.354465 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] apps.populate(settings.INSTALLED_APPS)
[Fri Jul 24 12:37:44.354476 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 85, in populate
[Fri Jul 24 12:37:44.354590 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] app_config = AppConfig.create(entry)
[Fri Jul 24 12:37:44.354602 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 86, in create
[Fri Jul 24 12:37:44.354590 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] app_config = AppConfig.create(entry)
[Fri Jul 24 12:37:44.354602 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] File "/usr/local/lib/python2.7/dist-packages/django/apps/config.py", line 86, in create
[Fri Jul 24 12:37:44.354697 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] module = import_module(entry)
[Fri Jul 24 12:37:44.354708 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] File "/usr/lib/python2.7/importlib/__init__.py", line 37, in import_module
[Fri Jul 24 12:37:44.354765 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] __import__(name)
[Fri Jul 24 12:37:44.354793 2015] [:error] [pid 20446:tid 140024564070144] [remote 49.248.57.164:51213] ImportError: No module named allauth
[Fri Jul 24 12:37:45.251341 2015] [authz_core:debug] [pid 20447:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11938] AH01626: authorization result of Require all granted: granted, referer: http://edusamosa.in/
[Fri Jul 24 12:37:45.251496 2015] [authz_core:debug] [pid 20447:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11938] AH01626: authorization result of <RequireAny>: granted, referer: http://edusamosa.in/
[Fri Jul 24 12:37:45.251559 2015] [authz_core:debug] [pid 20447:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11938] AH01626: authorization result of Require all granted: granted, referer: http://edusamosa.in/
[Fri Jul 24 12:37:45.251496 2015] [authz_core:debug] [pid 20447:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11938] AH01626: authorization result of <RequireAny>: granted, referer: http://edusamosa.in/
[Fri Jul 24 12:37:45.251559 2015] [authz_core:debug] [pid 20447:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11938] AH01626: authorization result of Require all granted: granted, referer: http://edusamosa.in/
[Fri Jul 24 12:37:45.251565 2015] [authz_core:debug] [pid 20447:tid 140024656201472] mod_authz_core.c(802): [client 49.248.57.164:11938] AH01626: authorization result of <RequireAny>: granted, referer: http://edusamosa.in/
[Fri Jul 24 18:07:45.251722 2015] [:info] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] mod_wsgi (pid=20446, process='pom', application='www.edusamosa.in|'): Loading WSGI script '/home/ubuntu/pom/pom/wsgi.py'.
[Fri Jul 24 18:07:45.252817 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] mod_wsgi (pid=20446): Target WSGI script '/home/ubuntu/pom/pom/wsgi.py' cannot be loaded as Python module.
[Fri Jul 24 18:07:45.252831 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] mod_wsgi (pid=20446): Exception occurred processing WSGI script '/home/ubuntu/pom/pom/wsgi.py'.
[Fri Jul 24 18:07:45.252850 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] Traceback (most recent call last):
[Fri Jul 24 18:07:45.252870 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] File "/home/ubuntu/pom/pom/wsgi.py", line 19, in <module>
[Fri Jul 24 18:07:45.252850 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] Traceback (most recent call last):
[Fri Jul 24 18:07:45.252870 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] File "/home/ubuntu/pom/pom/wsgi.py", line 19, in <module>
[Fri Jul 24 18:07:45.252913 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] application = get_wsgi_application()
[Fri Jul 24 18:07:45.252923 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] File "/usr/local/lib/python2.7/dist-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Fri Jul 24 18:07:45.252940 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] django.setup()
[Fri Jul 24 18:07:45.252948 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] File "/usr/local/lib/python2.7/dist-packages/django/__init__.py", line 18, in setup
[Fri Jul 24 18:07:45.252961 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] apps.populate(settings.INSTALLED_APPS)
[Fri Jul 24 18:07:45.252969 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 78, in populate
[Fri Jul 24 18:07:45.252981 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] raise RuntimeError("populate() isn't reentrant")
#
# [Fri Jul 24 18:07:45.252969 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] File "/usr/local/lib/python2.7/dist-packages/django/apps/registry.py", line 78, in populate
[Fri Jul 24 18:07:45.252981 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] raise RuntimeError("populate() isn't reentrant")
[Fri Jul 24 18:07:45.252996 2015] [:error] [pid 20446:tid 140024648070912] [remote 49.248.57.164:58879] RuntimeError: populate() isn't reentrant
~
My pom.settings.py is as follow:
"""
Django settings for pom project.
Generated by 'django-admin startproject' using Django 1.8.2.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.8/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(os.path.abspath(__file__)))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.8/howto/deployment/checklist/
ALLOWED_HOSTS = ['*']
# Application definition
'''
STATICFILES_FINDERS = (
'django.contrib.staticfiles.finders.FileSystemFinder',
'django.contrib.staticfiles.finders.AppDirectoriesFinder',
# 'django.contrib.staticfiles.finders.DefaultStorageFinder',
# other finders..
# 'compressor.finders.CompressorFinder',
)
'''
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',
'django.contrib.staticfiles',
'blog',
'ckeditor',
'reviewandrating',
'links',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.socialaccount.providers.facebook',
'allauth.socialaccount.providers.google',
'allauth.socialaccount.providers.linkedin',
'import_export',
'haystack',
'mathfilters',
)
# Ankur's Setting.py
AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend',
)
TEMPLATE_CONTEXT_PROCESSORS = (
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.debug',
"django.core.context_processors.request",
'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',
'django.core.context_processors.request',
'allauth.account.context_processors.account',
)
SITE_ID = 3
AUTH_PROFILE_MODULE = 'links.UserProfile'
LOGIN_URL = '/'
SOCIALACCOUNT_ADAPTER = 'links.my_adapter.MyAdapter'
SOCIALACCOUNT_QUERY_EMAIL = True
SOCIALACCOUNT_PROVIDERS = {
'facebook': {
'SCOPE': ['email'],
'AUTH_PARAMS': {'auth_type': 'reauthenticate'},
'METHOD': 'js_sdk',
'VERIFIED_EMAIL': False
},
'google':
{'SCOPE': ['profile', 'email'],
'AUTH_PARAMS': {'access_type': 'online'}},
'linkedin':
{'SCOPE': ['r_emailaddress'],
'PROFILE_FIELDS': ['id',
'first-name',
'last-name',
'email-address',
'picture-url',
'public-profile-url']}
}
LOGIN_REDIRECT_URL = '/'
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 = 'pom.urls'
TEMPLATES = [
{
'BACKEND': 'django.template.backends.django.DjangoTemplates',
'DIRS': ['/home/ubuntu/pom/templates/'], # This is where you add the template directory
'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',
'allauth.account.context_processors.account',
'allauth.socialaccount.context_processors.socialaccount',
],
},
},
]
WSGI_APPLICATION = 'pom.wsgi.application'
HAYSTACK_CONNECTIONS = {
'default': {
'ENGINE': 'haystack.backends.solr_backend.SolrEngine',
'URL': 'http://localhost:8983/solr/',
'TIMEOUT': 60 * 5,
'INCLUDE_SPELLING': True,
'BATCH_SIZE': 100,
'EXCLUDED_INDEXES': ['thirdpartyapp.search_indexes.BarIndex'],
}
}
# Database
# https://docs.djangoproject.com/en/1.8/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'hidden',
'USER': 'ubuntu',
'PASSWORD': '',
'HOST': 'localhost',
'PORT': '3306',
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.8/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'Asia/Kolkata'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.8/howto/static-files/
STATIC_URL = '/static/'
STATICFILES_DIRS = (
'',
'/home/ubuntu/pom/static/img/',
'/home/ubuntu/pom/static/css/',
'/home/ubuntu/pom/static/js/',
)
# TEMPLATE_LOADERS = (
# 'django.template.loaders.filesystem.Loader',
# 'django.template.loaders.app_directories.Loader',
# #django.template.loaders.eggs.Loader',
# )
TEMPLATE_DIRS = (
# os.path.join(BASE_DIR, 'templates'),
'/home/ubuntu/pom/templates/',
)
CKEDITOR_CONFIGS = {
'default': {
'toolbar': 'full',
'height': 300,
'width': 900,
},
}
CKEDITOR_UPLOAD_PATH = "uploads/"
CKEDITOR_IMAGE_BACKEND = 'Pillow'
CKEDITOR_JQUERY_URL = '//ajax.googleapis.com/ajax/libs/jquery/2.1.1/jquery.min.js'
STATIC_ROOT = '/home/ubuntu/pom/static/'
MEDIA_ROOT = '/home/ubuntu/pom/media/'
MEDIA_URL = '/media/'
HAYSTACK_SIGNAL_PROCESSOR = 'haystack.signals.RealtimeSignalProcessor'
The wsgi.py file is as follows:
"""
WSGI config for pom project.
It exposes the WSGI callable as a module-level variable named ``application``.
For more information on this file, see
https://docs.djangoproject.com/en/1.8/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
import sys
from os.path import abspath, dirname, join
#sys.path.insert(0, '/home/ubuntu/deploy/pom')
sys.path.insert(0, abspath(join(dirname(__file__), "../")))
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "pom.settings")
application = get_wsgi_application()
The error messages clearly says:
ImportError: No module named allauth
The populate() not reentrant error is an error that occurs when mod_wsgi attempts to reload the WSGI script file, after the first error, and finds that Django was half initialised due to first error and so it gives up.
Fix the issue with allauth module not being found and the latter error should go away.