I'm trying to configure the WSGI in Apache to work with Django but it's not working, when I go to domain.com it gives me an error 500.
But If I start Django using:
python manage.py runserver domain.com:8000
When I go to domain.com:8000 works perfectly so I think It's something about apache and WSGI.
Here you have my WSGI script:
import os
import sys
sys.path.append('/var/www/domain/')
os.environ['DJANGO_SETTINGS_MODULE'] = 'domain.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
My VirtualHost configuration:
<VirtualHost *:80>
# The ServerName directive sets the request scheme, hostname and port that
# 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 www.domain.com
ServerAdmin info#domain.com
ServerAlias domain.com
DocumentRoot /var/www/domain
WSGIScriptAlias / /var/www/domain/domain.wsgi
#Alias /static/ /var/www/domain/static/
# 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
# after it has been globally disabled with "a2disconf".
#Include conf-available/serve-cgi-bin.conf
</VirtualHost>
I'm using Ubuntu 14.04. I tried looking at logs but I have no idea what's wrong.
Logs:
[Thu Sep 25 10:15:09.549670 2014] [:error] [pid 17141] [client 88.12.185.72:65477] mod_wsgi (pid=17141): Exception occurred processing WSGI script '/var/www/domain/domain.wsgi'.
[Thu Sep 25 10:15:09.549722 2014] [:error] [pid 17141] [client 88.12.185.72:65477] Traceback (most recent call last):
[Thu Sep 25 10:15:09.549747 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi.py", line 187, in __call__
[Thu Sep 25 10:15:09.549880 2014] [:error] [pid 17141] [client 88.12.185.72:65477] response = self.get_response(request)
[Thu Sep 25 10:15:09.549899 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 199, in get_response
[Thu Sep 25 10:15:09.550029 2014] [:error] [pid 17141] [client 88.12.185.72:65477] response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Thu Sep 25 10:15:09.550048 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 236, in handle_uncaught_exception
[Thu Sep 25 10:15:09.550075 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return debug.technical_500_response(request, *exc_info)
[Thu Sep 25 10:15:09.550091 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 91, in technical_500_response
[Thu Sep 25 10:15:09.550492 2014] [:error] [pid 17141] [client 88.12.185.72:65477] html = reporter.get_traceback_html()
[Thu Sep 25 10:15:09.550513 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/views/debug.py", line 350, in get_traceback_html
[Thu Sep 25 10:15:09.550539 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return t.render(c)
[Thu Sep 25 10:15:09.550554 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 148, in render
[Thu Sep 25 10:15:09.550984 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return self._render(context)
[Thu Sep 25 10:15:09.551006 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 142, in _render
[Thu Sep 25 10:15:09.551034 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return self.nodelist.render(context)
[Thu Sep 25 10:15:09.551048 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 844, in render
[Thu Sep 25 10:15:09.551071 2014] [:error] [pid 17141] [client 88.12.185.72:65477] bit = self.render_node(node, context)
[Thu Sep 25 10:15:09.551084 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 80, in render_node
[Thu Sep 25 10:15:09.551174 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return node.render(context)
[Thu Sep 25 10:15:09.551192 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/debug.py", line 90, in render
[Thu Sep 25 10:15:09.551217 2014] [:error] [pid 17141] [client 88.12.185.72:65477] output = self.filter_expression.resolve(context)
[Thu Sep 25 10:15:09.551231 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/base.py", line 624, in resolve
[Thu Sep 25 10:15:09.551268 2014] [:error] [pid 17141] [client 88.12.185.72:65477] new_obj = func(obj, *arg_vals)
[Thu Sep 25 10:15:09.551284 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/template/defaultfilters.py", line 769, in date
[Thu Sep 25 10:15:09.551595 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return format(value, arg)
[Thu Sep 25 10:15:09.551615 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 343, in format
[Thu Sep 25 10:15:09.551759 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return df.format(format_string)
[Thu Sep 25 10:15:09.551778 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 35, in format
[Thu Sep 25 10:15:09.551817 2014] [:error] [pid 17141] [client 88.12.185.72:65477] pieces.append(force_text(getattr(self, piece)()))
[Thu Sep 25 10:15:09.551834 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 268, in r
[Thu Sep 25 10:15:09.551857 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return self.format('D, j M Y H:i:s O')
[Thu Sep 25 10:15:09.551871 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/dateformat.py", line 35, in format
[Thu Sep 25 10:15:09.551892 2014] [:error] [pid 17141] [client 88.12.185.72:65477] pieces.append(force_text(getattr(self, piece)()))
[Thu Sep 25 10:15:09.551907 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/encoding.py", line 85, in force_text
[Thu Sep 25 10:15:09.552021 2014] [:error] [pid 17141] [client 88.12.185.72:65477] s = six.text_type(s)
[Thu Sep 25 10:15:09.552039 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/functional.py", line 144, in __text_cast
[Thu Sep 25 10:15:09.552276 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return func(*self.__args, **self.__kw)
[Thu Sep 25 10:15:09.552297 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/__init__.py", line 83, in ugettext
[Thu Sep 25 10:15:09.552412 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return _trans.ugettext(message)
[Thu Sep 25 10:15:09.552431 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 325, in ugettext
[Thu Sep 25 10:15:09.552686 2014] [:error] [pid 17141] [client 88.12.185.72:65477] return do_translate(message, 'ugettext')
[Thu Sep 25 10:15:09.552706 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 306, in do_translate
[Thu Sep 25 10:15:09.552731 2014] [:error] [pid 17141] [client 88.12.185.72:65477] _default = translation(settings.LANGUAGE_CODE)
[Thu Sep 25 10:15:09.552746 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 209, in translation
[Thu Sep 25 10:15:09.552768 2014] [:error] [pid 17141] [client 88.12.185.72:65477] default_translation = _fetch(settings.LANGUAGE_CODE)
[Thu Sep 25 10:15:09.552782 2014] [:error] [pid 17141] [client 88.12.185.72:65477] File "/usr/local/lib/python2.7/dist-packages/django/utils/translation/trans_real.py", line 189, in _fetch
[Thu Sep 25 10:15:09.552804 2014] [:error] [pid 17141] [client 88.12.185.72:65477] "The translation infrastructure cannot be initialized before the "
[Thu Sep 25 10:15:09.552830 2014] [:error] [pid 17141] [client 88.12.185.72:65477] AppRegistryNotReady: The translation infrastructure cannot be initialized before the apps registry is ready. Check that you don't make non-lazy gettext calls at import time.
Anyone knows what I'm doing wrong?
Thanks
I discover that the version of Django in my production server is 1.7.0 and in Development server is 1.6.4. After downgrade Django works fine.
sudo pip install django==1.6.4
Related
I'm using Ubuntu 14.04.
I create a django project under /opt/cashpro/python_app/cashsite/trunk/cash
and create a wsgi file cash.wsgi in the same directory
Here is the content of cash.wsgi
import os
import sys
path = '/opt/cashpro/python_app/cashsite/trunk/'
sys.path.insert(0, path)
from cash import settings
import django.core.management
sys.path.insert(1, '/opt/cashpro/python_app/cashsite/trunk/cash/')
django.core.management.setup_environ(settings)
utility = django.core.management.ManagementUtility()
command = utility.fetch_command('runserver')
command.validate()
import django.conf
import django.utils
django.utils.translation.activate(django.conf.settings.LANGUAGE_CODE)
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
and here is what I add to my httpd.conf:
<VirtualHost *:443>
ServerName www.abcd.org
DocumentRoot /var/www/test
SSLEngine on
SSLCipherSuite HIGH:+MEDIUM:!SSLv2:!EXP:!ADH:!aNULL:!eNULL:!NULL
SSLCertificateFile "/opt/certs/www.abcd.org.crt"
SSLCertificateKeyFile "/opt/ssl/www.abcd.key"
SSLCertificateChainFile "/opt/certs/DigiCertCA.crt"
#SSLCertificateChainFile "/opt/ssl/IntermediatesCA3.crt"
BrowserMatch ".*MSIE.*" \
nokeepalive ssl-unclean-shutdown \
downgrade-1.0 force-response-1.0
Alias /media-cash/ /opt/cashpro/cashfiles
<Directory /opt/cashpro/cashfiles>
Options MultiViews
AllowOverride None
Require all granted
</Directory>
WSGIPassAuthorization On
WSGIScriptAlias /site
/opt/cashpro/python_app/cashsite/trunk/cash/cash.wsgi
ErrorLog /var/log/apache2/serror.log
CustomLog /var/log/apache2/saccess.log common
</VirtualHost>
The problem is, when I visit https://www.abcd.org/site, it says
Forbidden
You don't have permission to access / on this server.
Apache Error log
[Thu Jul 20 22:24:56.263573 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] mod_wsgi (pid=4448): Target WSGI script
'/opt/cashpro/python_app/cashsite/trunk/cash/cash.wsgi' cannot be loaded as
Python module., referer: https://www.abcd.org
[Thu Jul 20 22:24:56.263816 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] mod_wsgi (pid=4448): Exception occurred
processing WSGI script
'/opt/cashpro/python_app/cashsite/trunk/cash/cash.wsgi'., referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.263978 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] Traceback (most recent call last):, referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.264085 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File
"/opt/cashpro/python_app/cashsite/trunk/cash/cash.wsgi", line 11, in
<module>, referer: https://www.abcd.org
[Thu Jul 20 22:24:56.264223 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] command =
utility.fetch_command('runserver'), referer: https://www.abcd.org
[Thu Jul 20 22:24:56.264261 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/local/lib/python2.7/dist-
packages/django/core/management/__init__.py", line 261, in fetch_command,
referer: https://www.abcd.org
[Thu Jul 20 22:24:56.264325 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] klass = load_command_class(app_name,
subcommand), referer: https://www.abcd.org
[Thu Jul 20 22:24:56.264360 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/local/lib/python2.7/dist-
packages/django/core/management/__init__.py", line 69, in
load_command_class, referer: https://www.abcd.org
[Thu Jul 20 22:24:56.264410 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] module =
import_module('%s.management.commands.%s' % (app_name, name)), referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.264452 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/local/lib/python2.7/dist-
packages/django/utils/importlib.py", line 35, in import_module, referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.264495 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] __import__(name), referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.264524 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/local/lib/python2.7/dist-
packages/django/core/management/commands/runserver.py", line 8, in <module>,
referer: https://www.abcd.org
[Thu Jul 20 22:24:56.264570 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] from django.core.servers.basehttp import
AdminMediaHandler, run, WSGIServerException, get_internal_wsgi_application,
referer: https://www.abcd.org
[Thu Jul 20 22:24:56.264599 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/local/lib/python2.7/dist-
packages/django/core/servers/basehttp.py", line 26, in <module>, referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.264637 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] from django.views import static, referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.264665 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/local/lib/python2.7/dist-
packages/django/views/static.py", line 95, in <module>, referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.264700 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] template_translatable =
ugettext_noop(u"Index of %(directory)s"), referer: https://www.abcd.org
[Thu Jul 20 22:24:56.264727 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/local/lib/python2.7/dist-
packages/django/utils/translation/__init__.py", line 75, in gettext_noop,
referer: https://www.abcd.org
[Thu Jul 20 22:24:56.264780 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] return _trans.gettext_noop(message),
referer: https://www.abcd.org
[Thu Jul 20 22:24:56.264821 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/local/lib/python2.7/dist-
packages/django/utils/translation/__init__.py", line 48, in __getattr__,
referer: https://www.abcd.org
[Thu Jul 20 22:24:56.264852 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] if settings.USE_I18N:, referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.264879 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/local/lib/python2.7/dist-
packages/django/utils/functional.py", line 184, in inner, referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.264912 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] self._setup(), referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.264938 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/local/lib/python2.7/dist-
packages/django/conf/__init__.py", line 42, in _setup, referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.264987 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] self._wrapped = Settings(settings_module),
referer: https://www.abcd.org
[Thu Jul 20 22:24:56.265015 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/local/lib/python2.7/dist-
packages/django/conf/__init__.py", line 135, in __init__, referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.265044 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] logging_config_func(self.LOGGING),
referer: https://www.abcd.org
[Thu Jul 20 22:24:56.265071 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/lib/python2.7/logging/config.py",
line 794, in dictConfig, referer: https://www.abcd.org
[Thu Jul 20 22:24:56.265116 2017] [:error] [pid 4448:tid 140570219427584] [
client xxx.xxx.xxx.xxx:3340] dictConfigClass(config).configure(),
referer: https://www.abcd.org
[Thu Jul 20 22:24:56.265151 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] File "/usr/lib/python2.7/logging/config.py",
line 576, in configure, referer: https://www.abcd.org
[Thu Jul 20 22:24:56.265201 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] '%r: %s' % (name, e)), referer:
https://www.abcd.org
[Thu Jul 20 22:24:56.265284 2017] [:error] [pid 4448:tid 140570219427584]
[client xxx.xxx.xxx.xxx:3340] ValueError: Unable to configure handler
'default': [Errno 13] Permission denied: '/opt/cash_site.log', referer:
https://www.abcd.org
Another python web app host the same server.But getting error
<VirtualHost *:80>
ServerAdmin webmaster#localhost
ServerName www.xyz.com
ServerAlias xyz.com
DocumentRoot /opt/nadasnapp/html
<Directory /opt/nadasnapp/html/>
Require all granted
AllowOverride All
</Directory>
LogLevel warn
##FOR NADA
Alias /media/ /opt/nadasnapp/python_app/NaDaWebPro/media/
<Directory /opt/nadasnapp/python_app/NaDaWebPro/media/>
Require all granted
AllowOverride All
</Directory>
Alias /static/ /opt/nadasnapp/python_app/NaDaWebPro/static_root/
<Directory /opt/nadasnapp/python_app/NaDaWebPro/static_root/>
Require all granted
AllowOverride All
</Directory>
#FOR NADA
WSGIPassAuthorization On
WSGIScriptAlias / /opt/nadasnapp/python_app/NaDaWebPro/nada/wsgi.py
<Directory /opt/nadasnapp/python_app/NaDaWebPro/nada>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
</VirtualHost>
The error is
[Sun Jul 23 04:23:14.151745 2017] [:error] [pid 4594:tid
139820915422976]
[client xxx.xxx.xxx.xxx:2244] mod_wsgi (pid=4594): Exception occurred
processing WSGI script
'/opt/nadasnapp/python_app/NaDaWebPro/nada/wsgi.py'.
[Sun Jul 23 04:23:14.151993 2017] [:error] [pid 4594:tid 139820915422976]
[client xxx.xxx.xxx.xxx:2244] Traceback (most recent call last):
[Sun Jul 23 04:23:14.152065 2017] [:error] [pid 4594:tid 139820915422976]
[client xxx.xxx.xxx.xxx:2244] File "/usr/local/lib/python2.7/dist-
packages/django/core/handlers/wsgi.py", line 219, in __call__
[Sun Jul 23 04:23:14.152135 2017] [:error] [pid 4594:tid 139820915422976]
[client xxx.xxx.xxx.xxx:2244] self.load_middleware()
[Sun Jul 23 04:23:14.152166 2017] [:error] [pid 4594:tid 139820915422976]
[client xxx.xxx.xxx.xxx:2244] File "/usr/local/lib/python2.7/dist-
packages/django/core/handlers/base.py", line 39, in load_middleware
[Sun Jul 23 04:23:14.152203 2017] [:error] [pid 4594:tid 1
39820915422976]
[client xxx.xxx.xxx.xxx:2244] for middleware_path in
settings.MIDDLEWARE_CLASSES:
[Sun Jul 23 04:23:14.152234 2017] [:error] [pid 4594:tid 139820915422976]
[client xxx.xxx.xxx.xxx:2244] File "/usr/local/lib/python2.7/dist-
packages/django/utils/functional.py", line 184, in inner
[Sun Jul 23 04:23:14.152319 2017] [:error] [pid 4594:tid 139820915422976]
[client xxx.xxx.xxx.xxx:2244] self._setup()
[Sun Jul 23 04:23:14.152357 2017] [:error] [pid 4594:tid 139820915422976]
[client xxx.xxx.xxx.xxx:2244] File "/usr/local/lib/python2.7/dist-
packages/django/conf/__init__.py", line 42, in _setup
[Sun Jul 23 04:23:14.152402 2017] [:error] [pid 4594:tid 139820915422976]
[client xxx.xxx.xxx.xxx:2244] self._wrapped =
Settings(settings_module)
[Sun Jul 23 04:23:14.152445 2017] [:error] [pid 4594:tid 139820915422976]
[client xxx.xxx.xxx.xxx:2244] File "/usr/local/lib/python2.7/dist-
packages/django/conf/__init__.py", line 95, in __init__
[Sun Jul 23 04:23:14.152484 2017] [:error] [pid 4594:tid 139820915422976]
[client xxx.xxx.xxx.xxx:2244] raise ImportError("Could not import
settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[Sun Jul 23 04:23:14.152540 2017] [:error] [pid 4594:tid 139820915422976]
[client xxx.xxx.xxx.xxx:2244] ImportError: Could not import settings
'cash.settings' (Is it on sys.path?): No module named cash.settings
The directory you gave as argument to the Directory directive was /opt/cashpro/cashfiles, it should be /opt/cashpro/python_app/cashsite/trunk/cash/. That is, where the WSGI script file is located.
My Django app was working fine, but now I'm getting a server error, the last thing I did was a reboot to my Centos7 Server and now I'm getting this error:
and this are my logs I'm using apache:
[Thu Mar 30 14:04:10.571843 2017] [:error] [pid 11335] [remote 10.221.50.100:24] mod_wsgi (pid=11335): Target WSGI script '/opt/btsystem/BTSystem/wsgi.py' cannot be loaded as Python module.
[Thu Mar 30 14:04:10.571991 2017] [:error] [pid 11335] [remote 10.221.50.100:24] mod_wsgi (pid=11335): Exception occurred processing WSGI script '/opt/btsystem/BTSystem/wsgi.py'.
[Thu Mar 30 14:04:10.572263 2017] [:error] [pid 11335] [remote 10.221.50.100:24] Traceback (most recent call last):
[Thu Mar 30 14:04:10.572544 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/opt/btsystem/BTSystem/wsgi.py", line 16, in <module>
[Thu Mar 30 14:04:10.572795 2017] [:error] [pid 11335] [remote 10.221.50.100:24] application = get_wsgi_application()
[Thu Mar 30 14:04:10.572919 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/site-packages/django/core/wsgi.py", line 13, in get_wsgi_application
[Thu Mar 30 14:04:10.573054 2017] [:error] [pid 11335] [remote 10.221.50.100:24] django.setup(set_prefix=False)
[Thu Mar 30 14:04:10.573107 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/site-packages/django/__init__.py", line 22, in setup
[Thu Mar 30 14:04:10.573170 2017] [:error] [pid 11335] [remote 10.221.50.100:24] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Thu Mar 30 14:04:10.573261 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/site-packages/django/utils/log.py", line 75, in configure_logging
[Thu Mar 30 14:04:10.573312 2017] [:error] [pid 11335] [remote 10.221.50.100:24] logging_config_func(logging_settings)
[Thu Mar 30 14:04:10.573369 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/logging/config.py", line 803, in dictConfig
[Thu Mar 30 14:04:10.573409 2017] [:error] [pid 11335] [remote 10.221.50.100:24] dictConfigClass(config).configure()
[Thu Mar 30 14:04:10.573455 2017] [:error] [pid 11335] [remote 10.221.50.100:24] File "/usr/lib64/python2.7/logging/config.py", line 585, in configure
[Thu Mar 30 14:04:10.573501 2017] [:error] [pid 11335] [remote 10.221.50.100:24] '%r: %s' % (name, e))
[Thu Mar 30 14:04:10.573567 2017] [:error] [pid 11335] [remote 10.221.50.100:24] ValueError: Unable to configure handler 'file': [Errno 13] Permission denied: '/opt/btsystem-logs/btsystem-debug.log'
Any idea?
The last line shows that Django doesn't have permission to write to the configured log file.
[Thu Mar 30 14:04:10.573567 2017] [:error] [pid 11335] [remote 10.221.50.100:24] ValueError: Unable to configure handler 'file': [Errno 13] Permission denied: '/opt/btsystem-logs/btsystem-debug.log'
Make sure the file /opt/btsystem-logs/btsystem-debug.log is writeable by the user running the Django server.
The main problem was that I needed to do the following to enable the virtual host from Apache:
firewall-cmd --get-active-zones
firewall-cmd --zone=public --add-port=80/tcp --permanent
firewall-cmd --reload
Needed to open the ports.
I am trying to deploy my django project on a windows server, using apache 2.4 with mod_wsgi and pythong 3.4.
Now when I could run apache just fine but I got Internal Server Error when going to localhost, I have this Internal Server Error. Then I looked at the error.log and found the following:
The 'Apache2.4' service is restarting.
The 'Apache2.4' service has restarted.
winnt:notice] [pid 7756:tid 528] AH00424: Parent: Received restart signal -- Restarting the server.
[Thu Sep 29 18:18:19.003503 2016] [wsgi:warn] [pid 7756:tid 528] mod_wsgi: Compiled for Python/3.4.2.
[Thu Sep 29 18:18:19.003503 2016] [wsgi:warn] [pid 7756:tid 528] mod_wsgi: Runtime using Python/3.4.3.
[Thu Sep 29 18:18:19.003503 2016] [mpm_winnt:notice] [pid 7756:tid 528] AH00455: Apache/2.4.23 (Win64) mod_wsgi/4.4.12 Python/3.4.3 configured -- resuming normal operations
[Thu Sep 29 18:18:19.003503 2016] [mpm_winnt:notice] [pid 7756:tid 528] AH00456: Apache Lounge VC10 Server built: Jul 9 2016 11:59:00
[Thu Sep 29 18:18:19.003503 2016] [core:notice] [pid 7756:tid 528] AH00094: Command line: 'C:\\Apache24\\bin\\httpd.exe -d C:/Apache24'
[Thu Sep 29 18:18:19.003503 2016] [mpm_winnt:notice] [pid 7756:tid 528] AH00418: Parent: Created child process 10400
[Thu Sep 29 18:18:19.347246 2016] [wsgi:warn] [pid 10400:tid 456] mod_wsgi: Compiled for Python/3.4.2.
[Thu Sep 29 18:18:19.347246 2016] [wsgi:warn] [pid 10400:tid 456] mod_wsgi: Runtime using Python/3.4.3.
[Thu Sep 29 18:18:19.987923 2016] [mpm_winnt:notice] [pid 10400:tid 456] AH00354: Child: Starting 64 worker threads.
[Thu Sep 29 18:18:21.003576 2016] [mpm_winnt:notice] [pid 7476:tid 460] AH00364: Child: All worker threads have exited.
[Thu Sep 29 18:18:27.175151 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] mod_wsgi (pid=10400): Target WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py' cannot be loaded as Python module.
[Thu Sep 29 18:18:27.175151 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] mod_wsgi (pid=10400): Exception occurred processing WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py'.
[Thu Sep 29 18:18:27.175151 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] Traceback (most recent call last):\r
[Thu Sep 29 18:18:27.175151 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "C:/EquipmentCalibration/equipcal/wsgi.py", line 16, in <module>\r
[Thu Sep 29 18:18:27.175151 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] application = get_wsgi_application()\r
[Thu Sep 29 18:18:27.176153 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "C:\\Python34\\lib\\site-packages\\django\\core\\wsgi.py", line 13, in get_wsgi_application\r
[Thu Sep 29 18:18:27.176153 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] django.setup(set_prefix=False)\r
[Thu Sep 29 18:18:27.177153 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "C:\\Python34\\lib\\site-packages\\django\\__init__.py", line 22, in setup\r
[Thu Sep 29 18:18:27.177153 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)\r
[Thu Sep 29 18:18:27.177153 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 53, in __getattr__\r
[Thu Sep 29 18:18:27.177153 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] self._setup(name)\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 41, in _setup\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] self._wrapped = Settings(settings_module)\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 97, in __init__\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] mod = importlib.import_module(self.SETTINGS_MODULE)\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "C:\\Python34\\Lib\\importlib\\__init__.py", line 109, in import_module\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] return _bootstrap._gcd_import(name[level:], package, level)\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "<frozen importlib._bootstrap>", line 2254, in _gcd_import\r
[Thu Sep 29 18:18:27.178128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "<frozen importlib._bootstrap>", line 2237, in _find_and_load\r
[Thu Sep 29 18:18:27.179154 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked\r
[Thu Sep 29 18:18:27.179154 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed\r
[Thu Sep 29 18:18:27.179154 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "<frozen importlib._bootstrap>", line 2254, in _gcd_import\r
[Thu Sep 29 18:18:27.179154 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "<frozen importlib._bootstrap>", line 2237, in _find_and_load\r
[Thu Sep 29 18:18:27.179154 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked\r
[Thu Sep 29 18:18:27.179154 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55759] ImportError: No module named 'equipcal'\r
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] mod_wsgi (pid=10400): Target WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py' cannot be loaded as Python module., referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] mod_wsgi (pid=10400): Exception occurred processing WSGI script 'C:/EquipmentCalibration/equipcal/wsgi.py'., referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] Traceback (most recent call last):\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "C:/EquipmentCalibration/equipcal/wsgi.py", line 16, in <module>\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] application = get_wsgi_application()\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "C:\\Python34\\lib\\site-packages\\django\\core\\wsgi.py", line 13, in get_wsgi_application\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] django.setup(set_prefix=False)\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "C:\\Python34\\lib\\site-packages\\django\\__init__.py", line 22, in setup\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.199128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.200129 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 53, in __getattr__\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.200129 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] self._setup(name)\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.200129 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 41, in _setup\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.200129 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] self._wrapped = Settings(settings_module)\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.200129 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "C:\\Python34\\lib\\site-packages\\django\\conf\\__init__.py", line 97, in __init__\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.200129 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] mod = importlib.import_module(self.SETTINGS_MODULE)\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "C:\\Python34\\Lib\\importlib\\__init__.py", line 109, in import_module\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] return _bootstrap._gcd_import(name[level:], package, level)\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "<frozen importlib._bootstrap>", line 2254, in _gcd_import\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "<frozen importlib._bootstrap>", line 2237, in _find_and_load\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "<frozen importlib._bootstrap>", line 2212, in _find_and_load_unlocked\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "<frozen importlib._bootstrap>", line 321, in _call_with_frames_removed\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "<frozen importlib._bootstrap>", line 2254, in _gcd_import\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "<frozen importlib._bootstrap>", line 2237, in _find_and_load\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] File "<frozen importlib._bootstrap>", line 2224, in _find_and_load_unlocked\r, referer: http://localhost:8090/calbase
[Thu Sep 29 18:18:27.201128 2016] [wsgi:error] [pid 10400:tid 1108] [client ::1:55760] ImportError: No module named 'equipcal'\r, referer: http://localhost:8090/calbase
Apparently it is calling problem with my wsgi.py inside of my project. Currently I am just using the default wsgi.py file created when startproject. So it is just this:
"""
WSGI config for equipcal 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.10/howto/deployment/wsgi/
"""
import os
from django.core.wsgi import get_wsgi_application
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "equipcal.settings")
application = get_wsgi_application()
And my current https.conf is like this:
# Change Python path used by the server.
WSGIPythonPath “/EquipmentCalibration”
# Make calls to http://localhost/ refer to the Python/WSGI-script located at the specified location.
WSGIScriptAlias / /EquipmentCalibration/equipcal/wsgi.py
# Make calls to http://localhost/static refer to the specified folder.
Alias /static/ /EquipmentCalibration/static
Alias /media/ /EquipmentCalibration/media
<Directory /EquipmentCalibration/static>
Require all granted
</Directory>
<Directory /EquipmentCalibration/media>
Require all granted
</Directory>
<Directory /EquipmentCalibration/equipcal>
<Files wsgi.py>
Require all granted
</Files>
</Directory>
I tried to do a bit of research around but didn't seem to find how should I configure it. Could somebody please shed some light on this please?
Hey I've been stuck on a problem for a while now where I can upload media files from my localhost to AWS S3, but when I deploy to EB/EC2 I'm getting a 504 gateway timeout when uploading media files. On my development server the uploads work fine and are stored in s3 without any problem.
I'm currently using django-storages but I have tried django-storages-redux and django-s3-storages and I have the same problem where it works on my localhost but on my deployed server I get the 504 Gateway Timeout and the file is not uploaded to s3.
I have my settings files broken out into dev and prod. In my prod settings I have the following:
# S3 FILE SETTINGS
AWS_STORAGE_BUCKET_NAME = 'project-assets'
AWS_S3_CUSTOM_DOMAIN = 'cdn.domain.com'
ASSETS_PREFIX = 'app' # prefix in the bucket
MEDIA_PREFIX = ASSETS_PREFIX + '/uploads/'
DEFAULT_FILE_STORAGE = 'core.storages.MediaStorage'
STATICFILES_STORAGE = 'core.storages.StaticStorage'
To test on development I simply move these settings to the bottom of my dev settings.
I have these custom prefixes to store it in a specific directory on s3.
# storages.py
from django.conf import settings
from storages.backends.s3boto import S3BotoStorage
class StaticStorage(S3BotoStorage):
def __init__(self, *args, **kwargs):
kwargs['location'] = settings.ASSETS_PREFIX
return super(StaticStorage, self).__init__(*args, **kwargs)
class MediaStorage(S3BotoStorage):
def __init__(self, *args, **kwargs):
kwargs['location'] = settings.MEDIA_PREFIX
return super(MediaStorage, self).__init__(*args, **kwargs)
I have gotten this error before on other projects, and it usually had to do with the AWS_REGION. I have tried also using that setting but have the same results. My S3 is stored in 'us-west-2' (default) so as far as I have read I don't need to specify the region.
Here is the stacktrace that appears in my logs when I try to upload on my deployed instance.
Traceback (most recent call last):
File "/opt/python/run/venv/lib/python3.4/site-packages/django/core/handlers/exception.py", line 39, in inner
[Tue Sep 27 16:01:31.991596 2016] [:error] [pid 13870] response = get_response(request)
[Tue Sep 27 16:01:31.991598 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/core/handlers/base.py", line 187, in _get_response
[Tue Sep 27 16:01:31.991600 2016] [:error] [pid 13870] response = self.process_exception_by_middleware(e, request)
[Tue Sep 27 16:01:31.991602 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/core/handlers/base.py", line 185, in _get_response
[Tue Sep 27 16:01:31.991604 2016] [:error] [pid 13870] response = wrapped_callback(request, *callback_args, **callback_kwargs)
[Tue Sep 27 16:01:31.991606 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/views/decorators/csrf.py", line 58, in wrapped_view
[Tue Sep 27 16:01:31.991608 2016] [:error] [pid 13870] return view_func(*args, **kwargs)
[Tue Sep 27 16:01:31.991609 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/viewsets.py", line 87, in view
[Tue Sep 27 16:01:31.991619 2016] [:error] [pid 13870] return self.dispatch(request, *args, **kwargs)
[Tue Sep 27 16:01:31.991621 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/views.py", line 474, in dispatch
[Tue Sep 27 16:01:31.991623 2016] [:error] [pid 13870] response = self.handle_exception(exc)
[Tue Sep 27 16:01:31.991625 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/views.py", line 434, in handle_exception
[Tue Sep 27 16:01:31.991626 2016] [:error] [pid 13870] self.raise_uncaught_exception(exc)
[Tue Sep 27 16:01:31.991628 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/views.py", line 471, in dispatch
[Tue Sep 27 16:01:31.991630 2016] [:error] [pid 13870] response = handler(request, *args, **kwargs)
[Tue Sep 27 16:01:31.991631 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/mixins.py", line 21, in create
[Tue Sep 27 16:01:31.991633 2016] [:error] [pid 13870] self.perform_create(serializer)
[Tue Sep 27 16:01:31.991634 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/mixins.py", line 26, in perform_create
[Tue Sep 27 16:01:31.991636 2016] [:error] [pid 13870] serializer.save()
[Tue Sep 27 16:01:31.991638 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/serializers.py", line 192, in save
[Tue Sep 27 16:01:31.991639 2016] [:error] [pid 13870] self.instance = self.create(validated_data)
[Tue Sep 27 16:01:31.991641 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/rest_framework/serializers.py", line 873, in create
[Tue Sep 27 16:01:31.991643 2016] [:error] [pid 13870] instance = ModelClass.objects.create(**validated_data)
[Tue Sep 27 16:01:31.991644 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/manager.py", line 85, in manager_method
[Tue Sep 27 16:01:31.991646 2016] [:error] [pid 13870] return getattr(self.get_queryset(), name)(*args, **kwargs)
[Tue Sep 27 16:01:31.991659 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/query.py", line 399, in create
[Tue Sep 27 16:01:31.991661 2016] [:error] [pid 13870] obj.save(force_insert=True, using=self.db)
[Tue Sep 27 16:01:31.991663 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/base.py", line 796, in save
[Tue Sep 27 16:01:31.991665 2016] [:error] [pid 13870] force_update=force_update, update_fields=update_fields)
[Tue Sep 27 16:01:31.991666 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/base.py", line 824, in save_base
[Tue Sep 27 16:01:31.991668 2016] [:error] [pid 13870] updated = self._save_table(raw, cls, force_insert, force_update, using, update_fields)
[Tue Sep 27 16:01:31.991670 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/base.py", line 908, in _save_table
[Tue Sep 27 16:01:31.991672 2016] [:error] [pid 13870] result = self._do_insert(cls._base_manager, using, fields, update_pk, raw)
[Tue Sep 27 16:01:31.991673 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/base.py", line 947, in _do_insert
[Tue Sep 27 16:01:31.991675 2016] [:error] [pid 13870] using=using, raw=raw)
[Tue Sep 27 16:01:31.991677 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/manager.py", line 85, in manager_method
[Tue Sep 27 16:01:31.991679 2016] [:error] [pid 13870] return getattr(self.get_queryset(), name)(*args, **kwargs)
[Tue Sep 27 16:01:31.991680 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/query.py", line 1045, in _insert
[Tue Sep 27 16:01:31.991682 2016] [:error] [pid 13870] return query.get_compiler(using=using).execute_sql(return_id)
[Tue Sep 27 16:01:31.991686 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 1053, in execute_sql
[Tue Sep 27 16:01:31.991688 2016] [:error] [pid 13870] for sql, params in self.as_sql():
[Tue Sep 27 16:01:31.991690 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 1006, in as_sql
[Tue Sep 27 16:01:31.991692 2016] [:error] [pid 13870] for obj in self.query.objs
[Tue Sep 27 16:01:31.991693 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 1006, in <listcomp>
[Tue Sep 27 16:01:31.991695 2016] [:error] [pid 13870] for obj in self.query.objs
[Tue Sep 27 16:01:31.991697 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 1005, in <listcomp>
[Tue Sep 27 16:01:31.991699 2016] [:error] [pid 13870] [self.prepare_value(field, self.pre_save_val(field, obj)) for field in fields]
[Tue Sep 27 16:01:31.991701 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/sql/compiler.py", line 955, in pre_save_val
[Tue Sep 27 16:01:31.991702 2016] [:error] [pid 13870] return field.pre_save(obj, add=True)
[Tue Sep 27 16:01:31.991704 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/fields/files.py", line 292, in pre_save
[Tue Sep 27 16:01:31.991706 2016] [:error] [pid 13870] file.save(file.name, file, save=False)
[Tue Sep 27 16:01:31.991708 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/db/models/fields/files.py", line 91, in save
[Tue Sep 27 16:01:31.991709 2016] [:error] [pid 13870] self.name = self.storage.save(name, content, max_length=self.field.max_length)
[Tue Sep 27 16:01:31.991711 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/django/core/files/storage.py", line 54, in save
[Tue Sep 27 16:01:31.991713 2016] [:error] [pid 13870] return self._save(name, content)
[Tue Sep 27 16:01:31.991714 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/storages/backends/s3boto.py", line 413, in _save
[Tue Sep 27 16:01:31.991716 2016] [:error] [pid 13870] self._save_content(key, content, headers=headers)
[Tue Sep 27 16:01:31.991718 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/storages/backends/s3boto.py", line 424, in _save_content
[Tue Sep 27 16:01:31.991720 2016] [:error] [pid 13870] rewind=True, **kwargs)
[Tue Sep 27 16:01:31.991721 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/s3/key.py", line 1293, in set_contents_from_file
[Tue Sep 27 16:01:31.991723 2016] [:error] [pid 13870] chunked_transfer=chunked_transfer, size=size)
[Tue Sep 27 16:01:31.991725 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/s3/key.py", line 750, in send_file
[Tue Sep 27 16:01:31.991727 2016] [:error] [pid 13870] chunked_transfer=chunked_transfer, size=size)
[Tue Sep 27 16:01:31.991728 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/s3/key.py", line 951, in _send_file_internal
[Tue Sep 27 16:01:31.991730 2016] [:error] [pid 13870] query_args=query_args
[Tue Sep 27 16:01:31.991732 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/s3/connection.py", line 668, in make_request
[Tue Sep 27 16:01:31.991734 2016] [:error] [pid 13870] retry_handler=retry_handler
[Tue Sep 27 16:01:31.991735 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/connection.py", line 1071, in make_request
[Tue Sep 27 16:01:31.991737 2016] [:error] [pid 13870] retry_handler=retry_handler)
[Tue Sep 27 16:01:31.991739 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/connection.py", line 1030, in _mexe
[Tue Sep 27 16:01:31.991743 2016] [:error] [pid 13870] raise ex
[Tue Sep 27 16:01:31.991744 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/connection.py", line 940, in _mexe
[Tue Sep 27 16:01:31.991746 2016] [:error] [pid 13870] request.body, request.headers)
[Tue Sep 27 16:01:31.991748 2016] [:error] [pid 13870] File "/opt/python/run/venv/lib/python3.4/site-packages/boto/s3/key.py", line 844, in sender
[Tue Sep 27 16:01:31.991750 2016] [:error] [pid 13870] http_conn.send(chunk)
[Tue Sep 27 16:01:31.991751 2016] [:error] [pid 13870] File "/usr/lib64/python3.4/http/client.py", line 917, in send
[Tue Sep 27 16:01:31.991753 2016] [:error] [pid 13870] self.sock.sendall(data)
[Tue Sep 27 16:01:31.991755 2016] [:error] [pid 13870] File "/usr/lib64/python3.4/ssl.py", line 723, in sendall
[Tue Sep 27 16:01:31.991756 2016] [:error] [pid 13870] v = self.send(data[count:])
[Tue Sep 27 16:01:31.991758 2016] [:error] [pid 13870] File "/usr/lib64/python3.4/ssl.py", line 684, in send
[Tue Sep 27 16:01:31.991760 2016] [:error] [pid 13870] v = self._sslobj.write(data)
[Tue Sep 27 16:01:31.991763 2016] [:error] [pid 13870] ConnectionResetError: [Errno 104] Connection reset by peer
I thought maybe there was a problem with ssl (everything is on https) and tried setting the AWS_S3_SECURE_URLS = True setting but have the same result.
I've also tried turning off the https redirect and uploading through http:// and have the same result again.
Any ideas are welcome, thanks in advance!
Well, as expected it was something very simple. I didn't load my id/key into the environment variables.
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.