So I currently have installed Celery 3.1.8 (Cipater) and Djcelery 3.1.1 but following the tutorial causes my site to crash
So this tutorial
http://docs.celeryproject.org/en/master/django/first-steps-with-django.html#django-first-steps
I pretty much follow but when I try importing django-celery with this line in settings.py
import djcelery
I get a server error. Looking at the error log it says
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120] mod_wsgi (pid=32567): Exception occurred processing WSGI script '/srv/www/site/app1/wsgi_app1.py'.
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120] Traceback (most recent call last):
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi_app1.py", line 236, in __call__
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120] self.load_middleware()
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 45, in load_middleware
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120] for middleware_path in settings.MIDDLEWARE_CLASSES:
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 52, in __getattr__
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120] self._setup(name)
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 47, in _setup
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120] self._wrapped = Settings(settings_module)
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 132, in __init__
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120] raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[Fri Jan 24 00:47:40 2014] [error] [client 24.61.15.120] ImportError: Could not import settings 'site.settings_app1' (Is it on sys.path?): cannot import name Celery
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120] mod_wsgi (pid=32567): Exception occurred processing WSGI script '/srv/www/site/app1/wsgi_app1.py'.
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120] Traceback (most recent call last):
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/wsgi_app1.py", line 236, in __call__
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120] self.load_middleware()
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120] File "/usr/local/lib/python2.7/dist-packages/django/core/handlers/base.py", line 45, in load_middleware
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120] for middleware_path in settings.MIDDLEWARE_CLASSES:
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 52, in __getattr__
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120] self._setup(name)
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 47, in _setup
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120] self._wrapped = Settings(settings_module)
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120] File "/usr/local/lib/python2.7/dist-packages/django/conf/__init__.py", line 132, in __init__
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120] raise ImportError("Could not import settings '%s' (Is it on sys.path?): %s" % (self.SETTINGS_MODULE, e))
[Fri Jan 24 00:47:41 2014] [error] [client 24.61.15.120] ImportError: Could not import settings 'site.settings_app1' (Is it on sys.path?): cannot import name Celery
I'm not sure how to even move on. That import is literally what's causing the problem and I need to use djcelery to utilize the Django backend stuff
Edit:
I'm aware that you don't need djcelery for most things but in the release notes for 3.1 it says
http://docs.celeryproject.org/en/master/whatsnew-3.1.html#django-supported-out-of-the-box
Some features still require the django-celery library:
Celery does not implement the Django database or cache result backends.
Celery does not ship with the database-based periodic task
scheduler.
And I want to use my DB as the backend
Well, this still is an issue but I learned that you actually don't need django-celery at all to allow DB saves so I'm going to consider this answered
Related
I am running a web application developed in Django. When the appication is run, it is giving internal server error.
Here is the apache log
[Fri May 27 23:15:32 2016] [error] [client 203.110.245.243] mod_wsgi (pid=554): Target WSGI script '/home/randUser/DisCern/DisCern/wsgi.py' cannot be loaded as Python module.
[Fri May 27 23:15:32 2016] [error] [client 203.110.245.243] mod_wsgi (pid=554): Exception occurred processing WSGI script '/home/randUser/DisCern/DisCern/wsgi.py'.
[Fri May 27 23:15:32 2016] [error] [client 203.110.245.243] Traceback (most recent call last):
[Fri May 27 23:15:32 2016] [error] [client 203.110.245.243] File "/home/ankesh/DisCern/DisCern/wsgi.py", line 25, in <module>
[Fri May 27 23:15:32 2016] [error] [client 203.110.245.243] application = get_wsgi_application()
[Fri May 27 23:15:32 2016] [error] [client 203.110.245.243] File "/home/ankesh/DisCern/env/lib/python2.7/site-packages/django/core/wsgi.py", line 14, in get_wsgi_application
[Fri May 27 23:15:32 2016] [error] [client 203.110.245.243] django.setup()
[Fri May 27 23:15:32 2016] [error] [client 203.110.245.243] File "/home/ankesh/DisCern/env/lib/python2.7/site-packages/django/__init__.py", line 20, in setup
[Fri May 27 23:15:32 2016] [error] [client 203.110.245.243] configure_logging(settings.LOGGING_CONFIG, settings.LOGGING)
[Fri May 27 23:15:32 2016] [error] [client 203.110.245.243] File "/home/ankesh/DisCern/env/lib/python2.7/site-packages/django/conf/__init__.py", line 46, in __getattr__
[Fri May 27 23:15:32 2016] [error] [client 203.110.245.243] self._setup(name)
[Fri May 27 23:15:32 2016] [error] [client 203.110.245.243] File "/home/ankesh/DisCern/env/lib/python2.7/site-packages/django/conf/__init__.py", line 42, in _setup
[Fri May 27 23:15:32 2016] [error] [client 203.110.245.243] self._wrapped = Settings(settings_module)
[Fri May 27 23:15:32 2016] [error] [client 203.110.245.243] File "/home/ankesh/DisCern/env/lib/python2.7/site-packages/django/conf/__init__.py", line 98, in __init__
[Fri May 27 23:15:32 2016] [error] [client 203.110.245.243] % (self.SETTINGS_MODULE, e)
[Fri May 27 23:15:32 2016] [error] [client 203.110.245.243] ImportError: Could not import settings 'DisCern.settings' (Is it on sys.path? Is there an import error in the settings file?): No module named DisCern.settings
Here is the wsgi.py file
import os
import sys
import site
# Add the site-packages of the chosen virtualenv to work with
site.addsitedir('~/DisCern/env/lib/python2.7/site-packages')
# Add the app's directory to the PYTHONPATH
sys.path.append('/home/ankesh/DisCern/DisCern')
os.environ.setdefault("DJANGO_SETTINGS_MODULE", "DisCern.settings")
# Activate your virtual env
activate_env=os.path.expanduser("/home/ankesh/DisCern/env/bin/activate_this.py")
execfile(activate_env, dict(__file__=activate_env))
from django.core.wsgi import get_wsgi_application
application = get_wsgi_application()
What can be the possible error?
this has been troubling me for a while and I cannot find anyone else suffering from the same problem as I am,
I've installed DjangoCMS 3.0.2 and on it, I'm trying to use cmsplugin_contact (I've done the integration and the pages load fine). It seems to work fine in debug mode, where a thank you message is shown on submission. Things go awry the moment I flip the DEBUG flag to False.
The Apache Server gives a '200 Error', which means that the request succeeded, but then something snapped. Examining the traceback in error logs, the CMS tags seem to be the culprit. Apparently, the request object is not being passed and I don't understand why.
Here's the traceback:
File "/home/craft/env/lib/python2.7/django/core/handlers/wsgi.py", line 255, in __call__
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] response = self.get_response(request)
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] File "/home/craft/env/lib/python2.7/django/core/handlers/base.py", line 178, in get_response
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] File "/home/craft/env/lib/python2.7/django/core/handlers/base.py", line 224, in handle_uncaught_exception
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] return callback(request, **param_dict)
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] File "/home/craft/env/lib/python2.7/django/utils/functional.py", line 15, in _curried
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] return _curried_func(*(args+moreargs), **dict(kwargs, **morekwargs))
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] File "/home/craft/env/lib/python2.7/django/utils/decorators.py", line 91, in _wrapped_view
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] response = view_func(request, *args, **kwargs)
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] File "/home/craft/env/lib/python2.7/django/views/defaults.py", line 41, in server_error
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] return http.HttpResponseServerError(template.render(Context({})))
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] File "/home/craft/env/lib/python2.7/django/template/base.py", line 140, in render
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] return self._render(context)
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] File "/home/craft/env/lib/python2.7/django/template/base.py", line 134, in _render
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] return self.nodelist.render(context)
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] File "/home/craft/env/lib/python2.7/django/template/base.py", line 830, in render
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] bit = self.render_node(node, context)
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] File "/home/craft/env/lib/python2.7/django/template/base.py", line 844, in render_node
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] return node.render(context)
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] File "/home/craft/env/lib/python2.7/classytags/core.py", line 106, in render
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] return self.render_tag(context, **kwargs)
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] File "/home/craft/env/lib/python2.7/sekizai/templatetags/sekizai_tags.py", line 75, in render_tag
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] return nodelist.render(context)
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] File "/home/craft/env/lib/python2.7/django/template/base.py", line 830, in render
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] bit = self.render_node(node, context)
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] File "/home/craft/env/lib/python2.7/django/template/base.py", line 844, in render_node
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] return node.render(context)
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] File "/home/craft/env/lib/python2.7/classytags/core.py", line 106, in render
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] return self.render_tag(context, **kwargs)
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] File "/home/craft/env/lib/python2.7/cms/templatetags/cms_tags.py", line 607, in render_tag
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] context['cms_toolbar_login_error'] = request.GET.get('cms-toolbar-login-error', False) == '1'
[Wed May 28 23:12:17 2014] [error] [client 127.0.0.1] AttributeError: 'NoneType' object has no attribute 'GET'
This problem had also arisen before, when I was not using the cmsplugin_contact module, but was resolved by setting the ALLOWED_HOSTS value and commenting out the TEMPLATE_DEBUG = DEBUG flags. Now, it doesn't seem to work. Any ideas?
I've just finished installing (or attempting to install) Django 1.6 on an EC2 server, but I seem to be having trouble with django.wsgi.
I've installed Django 1.6, httpd, and mod_wsgi, and I'm getting the "The server encountered an internal error or misconfiguration and was unable to complete your request.
Please contact the server administrator, root#localhost..."
I get that I've made a misstep somewhere, but I can't seem to make out what the error logs are trying to tell me. I see there are some database errors near the bottom, and I haven't gotten to setting any up yet, but surely the errors above are from a different issue?
Here's is the latest from the error log:
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] mod_wsgi (pid=1973): Exception occurred processing WSGI script '/home/ec2-user/Django-1.6/joshsite/apache/django.wsgi'.
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] Traceback (most recent call last):
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 187, in __call__
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] self.load_middleware()
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 47, in load_middleware
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] mw_class = import_by_path(middleware_path)
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/utils/module_loading.py", line 21, in import_by_path
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] module = import_module(module_path)
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/utils/importlib.py", line 40, in import_module
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] __import__(name)
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/contrib/auth/middleware.py", line 3, in <module>
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] from django.contrib.auth.backends import RemoteUserBackend
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/contrib/auth/backends.py", line 3, in <module>
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] from django.contrib.auth.models import Permission
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/contrib/auth/models.py", line 48, in <module>
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] class Permission(models.Model):
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 96, in __new__
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] new_class.add_to_class('_meta', Options(meta, **kwargs))
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 264, in add_to_class
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] value.contribute_to_class(cls, name)
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/db/models/options.py", line 124, in contribute_to_class
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/db/__init__.py", line 34, in __getattr__
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] return getattr(connections[DEFAULT_DB_ALIAS], item)
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/db/utils.py", line 198, in __getitem__
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] backend = load_backend(db['ENGINE'])
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/db/utils.py", line 131, in load_backend
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] raise ImproperlyConfigured(error_msg)
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] ImproperlyConfigured: 'mysql' isn't an available database backend.
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] Try using 'django.db.backends.XXX', where XXX is one of:
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] u'mysql', u'oracle', u'postgresql_psycopg2', u'sqlite3'
[Wed Apr 23 02:39:00 2014] [error] [client 75.75.80.82] Error was: No module named mysql.base
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] mod_wsgi (pid=1976): Exception occurred processing WSGI script '/home/ec2-user/Django-1.6/joshsite/apache/django.wsgi'.
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] Traceback (most recent call last):
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/core/handlers/wsgi.py", line 187, in __call__
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] self.load_middleware()
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/core/handlers/base.py", line 47, in load_middleware
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] mw_class = import_by_path(middleware_path)
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/utils/module_loading.py", line 21, in import_by_path
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] module = import_module(module_path)
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/utils/importlib.py", line 40, in import_module
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] __import__(name)
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/contrib/auth/middleware.py", line 3, in <module>
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] from django.contrib.auth.backends import RemoteUserBackend
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/contrib/auth/backends.py", line 3, in <module>
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] from django.contrib.auth.models import Permission
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/contrib/auth/models.py", line 48, in <module>
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] class Permission(models.Model):
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 96, in __new__
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] new_class.add_to_class('_meta', Options(meta, **kwargs))
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/db/models/base.py", line 264, in add_to_class
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] value.contribute_to_class(cls, name)
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/db/models/options.py", line 124, in contribute_to_class
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] self.db_table = truncate_name(self.db_table, connection.ops.max_name_length())
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/db/__init__.py", line 34, in __getattr__
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] return getattr(connections[DEFAULT_DB_ALIAS], item)
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/db/utils.py", line 198, in __getitem__
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] backend = load_backend(db['ENGINE'])
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] File "/usr/lib/python2.6/site-packages/django/db/utils.py", line 131, in load_backend
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] raise ImproperlyConfigured(error_msg)
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] ImproperlyConfigured: 'mysql' isn't an available database backend.
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] Try using 'django.db.backends.XXX', where XXX is one of:
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] u'mysql', u'oracle', u'postgresql_psycopg2', u'sqlite3'
[Wed Apr 23 02:39:03 2014] [error] [client 75.75.80.82] Error was: No module named mysql.base
My django.wsgi is as follows:
import os,sys
apache_configuration = os.path.dirname(__file__)
project = os.path.dirname(apache_configuration)
workspace = os.path.dirname(project)
sys.path.append(workspace)
sys.path.append('/home/ec2-user/Django-1.6/joshsite/joshsite')
sys.path.append('/home/ec2-user/Django-1.6/joshsite')
os.environ['DJANGO_SETTINGS_MODULE'] = 'joshsite.settings'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
And I've added this in to the httpd.conf
<VirtualHost *:80>
DocumentRoot /home/ec2-user/Django-1.6/joshsite
ServerName ec2-54-187-46-240.us-west-2.compute.amazonaws.com
ErrorLog /home/ec2-user/Django-1.6/joshsite/logs/apache_error.log
CustomLog /home/ec2-user/Django-1.6/joshsite/logs/apache_access.log combined
WSGIScriptAlias / /home/ec2-user/Django-1.6/apache/django.wsgi
<Directory /home/ec2-user/Django-1.6/joshsite/media>
Order deny,allow
Allow from all
</Directory>
<Directory /home/ec2-user/Django-1.6/apache>
Order deny,allow
Allow from all
</Directory>
LogLevel warn
Alias /media/ /ec2-user/Django-1.6/joshsite/media/
</VirtualHost>
Here are the contents of settings.py:
"""
Django settings for joshsite project.
For more information on this file, see
https://docs.djangoproject.com/en/1.6/topics/settings/
For the full list of settings and their values, see
https://docs.djangoproject.com/en/1.6/ref/settings/
"""
# Build paths inside the project like this: os.path.join(BASE_DIR, ...)
import os
BASE_DIR = os.path.dirname(os.path.dirname(__file__))
# Quick-start development settings - unsuitable for production
# See https://docs.djangoproject.com/en/1.6/howto/deployment/checklist/
# SECURITY WARNING: keep the secret key used in production secret!
SECRET_KEY = ***
# SECURITY WARNING: don't run with debug turned on in production!
DEBUG = True
TEMPLATE_DEBUG = True
ALLOWED_HOSTS = []
# Application definition
INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.messages',
'django.contrib.staticfiles',
)
MIDDLEWARE_CLASSES = (
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.common.CommonMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
'django.middleware.clickjacking.XFrameOptionsMiddleware',
)
ROOT_URLCONF = 'joshsite.urls'
WSGI_APPLICATION = 'joshsite.wsgi.application'
# Database
# https://docs.djangoproject.com/en/1.6/ref/settings/#databases
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.mysql',
'NAME': 'test',
'USER': '**',
'PASSWORD': '**',
'HOST': '',
'PORT': '',
}
}
# Internationalization
# https://docs.djangoproject.com/en/1.6/topics/i18n/
LANGUAGE_CODE = 'en-us'
TIME_ZONE = 'UTC'
USE_I18N = True
USE_L10N = True
USE_TZ = True
# Static files (CSS, JavaScript, Images)
# https://docs.djangoproject.com/en/1.6/howto/static-files/
STATIC_URL = '/static/'
Here is my urls.py:
from django.conf.urls import patterns, include, url
from django.contrib import admin
admin.autodiscover()
urlpatterns = patterns('',
# Examples:
# url(r'^$', 'joshsite.views.home', name='home'),
# url(r'^blog/', include('blog.urls')),
url(r'^admin/', include(admin.site.urls)),
url(r'^home/', 'joshsite.views.home', name='home'),
)
Update:
Sometimes at /, I get a 404 error:
Request Method: GET
Request URL: http://ec2-54-187-46-240.us-west-2.compute.amazonaws.com/
Using the URLconf defined in joshsite.urls, Django tried these URL patterns, in this order:
^admin/
^home/ [name='home']
The current URL, , didn't match any of these.
You're seeing this error because you have DEBUG = True in your Django settings file. Change that to False, and Django will display a standard 404 page.
Thank you in advance for any assistance.
But then after refreshing it sometimes goes back to a 500, almost as if chosen at random.
Check your DATABASE settings in settings.py. Looks like your ENGINE is bad. Try changing to:
'ENGINE': 'django.db.backends.mysql',
If this doesn't work, please post your database settings.
I am trying to deploy django application on Linux server with mod_wsgi.
Below are my setting for apache in httpd.conf file -
<VirtualHost 127.0.0.1:8080>
AddDefaultCharset utf-8
LogLevel warn
ServerName myappletrade.com
#WSGIProcessGroup appletrade
WSGIScriptAlias / /var/www/html/appletrade/django.wsgi
DocumentRoot /var/www/html/appletrade
#WSGIDaemonProcess frontend user=vasim group=www
ServerAlias myappletrade.com
CustomLog /var/www/html/appletrade/access_log combined
ErrorLog /var/www/html/appletrade/error_log
<Directory /var/www/html/appletrade>
Order allow,deny
Allow from all
</Directory>
</VirtualHost>
django.wsgi file settings -
import os
import sys
sys.path.insert(0, "appletrade")
sys.path.insert(0, "/var/www/html/appletrade/noneapp/env/lib/python2.6/site-packages" )
os.environ['DJANGO_SETTINGS_MODULE'] = 'noneapp.settings.development'
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()
inside noneapp folder I have setting files for development ,production server.
When I am trying to for myappletrade.com in browser nothing happens.it shows 500 internal server error.
I have checked error log . where it's saying -
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] mod_wsgi (pid=2828): Exception occurred processing WSGI script '/var/www/html/appletrade/django.wsgi'.
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] Traceback (most recent call last):
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] File "/usr/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 241, in __call__
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] response = self.get_response(request)
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 179, in get_response
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] response = self.handle_uncaught_exception(request, resolver, sys.exc_info())
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py", line 224, in handle_uncaught_exception
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] if resolver.urlconf_module is None:
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] File "/usr/lib/python2.7/site-packages/django/core/urlresolvers.py", line 323, in urlconf_module
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] self._urlconf_module = import_module(self.urlconf_name)
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] File "/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] __import__(name)
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] File "/var/www/html/appletrade/noneapp/urls/production.py", line 4, in <module>
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] from noneapp.urls.default import urlpatterns as default_urlpatterns
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] File "/var/www/html/appletrade/noneapp/urls/default.py", line 6, in <module>
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] url(r'^catalog/', include('appletrade.urls', namespace = "catalog")),
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] File "/usr/lib/python2.7/site-packages/django/conf/urls/__init__.py", line 24, in include
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] urlconf_module = import_module(urlconf_module)
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] File "/usr/lib/python2.7/site-packages/django/utils/importlib.py", line 35, in import_module
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] __import__(name)
[Sat Mar 30 18:07:55 2013] [error] [client 127.0.0.1] ImportError: No module named urls
Please check my configuration setting and Let me know if I am missing something.
Thanks in Advance
You are trying to force Python 2.7 to use Python 2.6 libraries. Your django.wsgi lists the python2.6 site packages in the path, but the errors all list python2.7.
Are you using a virtualenv environment as well? Make sure you're using the python installed in that virtual environment, and not the system version - you will be missing any pip installed packages you have.
Upon further review - you don't have all of your variables defined for mod_wsgi in your VirtualHost configuration, either.
Dear Python/Django expert,
Due to recent server migration, my python-powered django app throws a 500 page. The log file is listed below. Can you please give me some help in diagnosing this problem?
==========================
[haiyang#web aihaiyang]$ tail ~/logs/user/error_django_aihaiyang_log
[Fri Jun 29 17:25:57 2012] [error] [client 127.0.0.1] return callback(request, **param_dict), referer: http://aihaiyang.com/synlex/syntactic/
[Fri Jun 29 17:25:57 2012] [error] [client 127.0.0.1] File "/home/haiyang/webapps/django_aihaiyang/lib/python2.5/django/utils/decorators.py", line 93, in _wrapped_view, referer: http://aihaiyang.com/synlex/syntactic/
[Fri Jun 29 17:25:57 2012] [error] [client 127.0.0.1] response = view_func(request, *args, **kwargs), referer: http://aihaiyang.com/synlex/syntactic/
[Fri Jun 29 17:25:57 2012] [error] [client 127.0.0.1] File "/home/haiyang/webapps/django_aihaiyang/lib/python2.5/django/views/defaults.py", line 30, in server_error, referer: http://aihaiyang.com/synlex/syntactic/
[Fri Jun 29 17:25:57 2012] [error] [client 127.0.0.1] t = loader.get_template(template_name) # You need to create a 500.html template., referer: http://aihaiyang.com/synlex/syntactic/
[Fri Jun 29 17:25:57 2012] [error] [client 127.0.0.1] File "/home/haiyang/webapps/django_aihaiyang/lib/python2.5/django/template/loader.py", line 157, in get_template, referer: http://aihaiyang.com/synlex/syntactic/
[Fri Jun 29 17:25:57 2012] [error] [client 127.0.0.1] template, origin = find_template(template_name), referer: http://aihaiyang.com/synlex/syntactic/
[Fri Jun 29 17:25:57 2012] [error] [client 127.0.0.1] File "/home/haiyang/webapps/django_aihaiyang/lib/python2.5/django/template/loader.py", line 138, in find_template, referer: http://aihaiyang.com/synlex/syntactic/
[Fri Jun 29 17:25:57 2012] [error] [client 127.0.0.1] raise TemplateDoesNotExist(name), referer: http://aihaiyang.com/synlex/syntactic/
[Fri Jun 29 17:25:57 2012] [error] [client 127.0.0.1] TemplateDoesNotExist: 500.html, referer: http://aihaiyang.com/synlex/syntactic/
=========================
Thanks,
Haiyang
You need to create a 500.html template and put it in your template_dir
Template does not exist: 500.html