views:

27

answers:

0

Hi,

I have successfully been running my django based page for some time. Now I thought I'd turn of debug mode and implement a nice 404.html file. The problem is that as soon as I change DEBUG to 'False' in my settings.py I immediately get server errors that I don't understand, no matter what page I try to visit. Existing pages or non-existing pages (that should show my 404.html) all give errors.

I'm running django on dreamhost using passenger. In order to get useful error messages to begin with I followed the instructions on dreamhosts wiki and set up my passenger_wsgi.py file according to these instructions using the module paste. This is my passenger_wsgi.py:

import sys, os
INTERP = "/home/bhogberg/bin/python"
if sys.executable != INTERP: os.execl(INTERP, INTERP, *sys.argv)
cwd = os.getcwd()
myapp_directory = cwd + '/homepage'
sys.stdout = sys.stderr
sys.path.insert(0,myapp_directory)
sys.path.append(os.getcwd())
os.environ['DJANGO_SETTINGS_MODULE'] = "homepage.settings"
import django.core.handlers.wsgi
from paste.exceptions.errormiddleware import ErrorMiddleware
application = django.core.handlers.wsgi.WSGIHandler()
# To cut django out of the loop, comment the above application = ... line ,
# and remove "test" from the below function definition.
def testapplication(environ, start_response):
    status = '200 OK'
    output = 'Hello World! Running Python version ' + sys.version + '\n\n'
    response_headers = [('Content-type', 'text/plain'),
                        ('Content-Length', str(len(output)))]
    #to test paste's error catching prowess, uncomment the following line
    #while this function is the "application"
    #raise("error")
    start_response(status, response_headers)
    return [output]
application = ErrorMiddleware(application, debug=True)

I have tried to also change that last line's debug to False, I get errors in that case too.

Everything works fine as long as I have DEBUG=True in settings.py

This is the errors I get when just turning Debug=False on (reported via paste, and not django's error messages):

Server Error

Module paste.exceptions.errormiddleware:144 in __call__
<<              __traceback_supplement__ = Supplement, self, environ
                sr_checker = ResponseStartChecker(start_response)
                app_iter = self.application(environ, sr_checker)
                return self.make_catching_iter(app_iter, environ, sr_checker)
            except:
Module django.core.handlers.wsgi:241 in __call__
<<                  response = http.HttpResponseBadRequest()
                else:
                    response = self.get_response(request)

                    # Apply response middleware
Module django.core.handlers.base:142 in get_response
<<                  exc_info = sys.exc_info()
                    receivers = signals.got_request_exception.send(sender=self.__class__, request=request)
                    return self.handle_uncaught_exception(request, resolver, exc_info)
            finally:
                # Reset URLconf for this thread on the way out for complete
Module django.core.handlers.base:177 in handle_uncaught_exception
<<          mail_admins(subject, message, fail_silently=True)
            # If Http500 handler is not installed, re-raise last exception
            if resolver.urlconf_module is None:
                raise exc_info[1], None, exc_info[2]
            # Return an HttpResponse that displays a friendly error message.

Module django.core.urlresolvers:238 in _get_urlconf_module
<<              return self._urlconf_module
            except AttributeError:
                self._urlconf_module = import_module(self.urlconf_name)
                return self._urlconf_module
        urlconf_module = property(_get_urlconf_module)
Module django.utils.importlib:35 in import_module
<<              level += 1
            name = _resolve_name(name[level:], package, level)
        __import__(name)
        return sys.modules[name]
Module ?:3 in <module>
<<  from django.conf.urls.defaults import *
    from django.contrib import admin
    admin.autodiscover()

    import os.path
Module django.contrib.admin:24 in autodiscover
<<          try:
                before_import_registry = copy.copy(site._registry)
                import_module('%s.admin' % app)
            except:
                # Reset the model registry to the state before the last import as

Module django.utils.importlib:35 in import_module
<<              level += 1
            name = _resolve_name(name[level:], package, level)
        __import__(name)
        return sys.modules[name]
Module ?:6 in <module>
<<  

    admin.site.register(Page, PageAdmin)
Module django.contrib.admin.sites:93 in register
<<  
                # Instantiate the admin class to save in the registry
                self._registry[model] = admin_class(model, self)

        def unregister(self, model_or_iterable):
Module feincms.module.page.models:634 in __init__
<<  
        def __init__(self, *args, **kwargs):
            if len(Page._feincms_templates) > 4:
                del(self.radio_fields['template_key'])
AttributeError: type object 'Page' has no attribute '_feincms_templates'