Search code examples
djangodreamhost

Moving to production environment broke my application


I've just deployed my application on dreamhost and it's stopped working when uploading files. Passenger just produces a 500 internal error. It works on my development set up.
My passenger file looks like:

import sys, os
sys.path.append(os.getcwd())
sys.path.append(os.path.join(os.getcwd(), '/photosoc'))

os.environ['DJANGO_SETTINGS_MODULE'] = "photosoc.settings"
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()

I get the standard 404 error(debug is still enabled). I have had to change my urls file though from:

from django.conf.urls.defaults import patterns, include, url
from competition.models import Image
from competition import *
from django.contrib import admin
from django.contrib.staticfiles.urls import staticfiles_urlpatterns
from django.conf import settings

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
admin.site.register(Image)

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'photosoc.views.home', name='home'),
    # url(r'^photosoc/', include('photosoc.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
#   url(r'^image/$', 'competition.views.index'),
    url(r'^image/uploadImage', 'competition.views.uploadImage'),
    url(r'^image/uploadCompleted', 'competition.views.uploadCompleted'),
    url(r'^image/uploadFailed', 'competition.views.uploadFailed'),
)

urlpatterns += patterns('',
    (r'^media/(?P<path>.*)$', 'django.views.static.serve', {'document_root': settings.MEDIA_ROOT}))

To the following:

from django.conf.urls.defaults import patterns, include, url
from competition.models import Image
from competition import *
from django.contrib import admin
from django.conf import settings

# Uncomment the next two lines to enable the admin:
from django.contrib import admin
admin.autodiscover()
admin.site.register(Image)

urlpatterns = patterns('',
    # Examples:
    # url(r'^$', 'photosoc.views.home', name='home'),
    # url(r'^photosoc/', include('photosoc.foo.urls')),

    # Uncomment the admin/doc line below to enable admin documentation:
    # url(r'^admin/doc/', include('django.contrib.admindocs.urls')),

    # Uncomment the next line to enable the admin:
    url(r'^admin/', include(admin.site.urls)),
#   url(r'^image/$', 'competition.views.index'),
    url(r'^image/uploadImage', 'competition.views.uploadImage'),
    url(r'^image/uploadCompleted', 'competition.views.uploadCompleted'),
    url(r'^image/uploadFailed', 'competition.views.uploadFailed'),
)

This is the only change I've made to the application from the switch from development to production. So what else could have gone wrong?


Solution

  • Are your settings exactly the same in what middleware classes your importing? Double check that these are the same.

    Related:

    ModSecurity: Output filter: Failed to read bucket (rc 104): Connection reset by peer