开发者

Django serving 500 errors for every view except root

So I am trying to deploy to my production environment and am getting 500 errors for every view except the root URL: http://5buckchuck.com/

The errors appear to apache errors, not the fancy django ones:

Internal Server Error

The server encountered an internal error or misconfiguration and was unable to complete your request.

Please contact the server administrator, webmaster@5buckchuck.com and inform them of the time the error occurred, and anything you might have done that may have caused the error.

More information about this error may be available in the server error log.

per the server error logs:

[Thu Jul 07 22:04:53 2011] [error] [client my IP] Request exceeded the limit of 10 internal redirects due to probable configuration error. Use 'LimitInternalRecursion' to increase the limit if necessary. Use 'LogLevel debug' to get a backtrace.

Info:

  • debugging is set to true
  • I have tried syncdb, all up to date
  • I have connected to the db and all looks well there开发者_如何学运维
  • urls.py seems to reflect all the urls in dev

I am not quite sure where to go here. Better logging would certainly help. Any help would be greatly appreciated.

Per request:

settings.py

DEBUG = True
TEMPLATE_DEBUG = DEBUG

TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.Loader',
'django.template.loaders.app_directories.Loader',
 #'django.template.loaders.eggs.Loader',
)

MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'django.contrib.sessions.middleware.SessionMiddleware',
'django.middleware.csrf.CsrfViewMiddleware',
'django.contrib.auth.middleware.AuthenticationMiddleware',
'django.contrib.messages.middleware.MessageMiddleware',
)

AUTHENTICATION_BACKENDS = (
'django.contrib.auth.backends.ModelBackend',
'allauth.account.auth_backends.AuthenticationBackend',
)

ROOT_URLCONF = 'fivebuckchuck.urls'

TEMPLATE_DIRS = (
'/home/MyUserName/5buckchuck.com/fivebuckchuck/templates'

)

INSTALLED_APPS = (
'django.contrib.admin',
'django.contrib.auth',
'django.contrib.contenttypes',
'django.contrib.sessions',
'django.contrib.sites',
'django.contrib.messages',

#5BC Stuff
'winerater',

#all-auth apps,
'emailconfirmation',
'uni_form',
'allauth',
'allauth.account',
'allauth.socialaccount',
'allauth.twitter',
'allauth.openid',
)


TEMPLATE_CONTEXT_PROCESSORS = (
'allauth.context_processors.allauth',
'allauth.account.context_processors.account',
'django.core.context_processors.media',
'django.contrib.auth.context_processors.auth',
'django.core.context_processors.request',
)

and the urls.py

from django.conf.urls.defaults import *
from winerater.views import *
from settings import MEDIA_ROOT
from django.views.generic.simple import direct_to_template
from django.views.generic.simple import redirect_to

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

urlpatterns = patterns('',
# Example:
# (r'^mobile_5BC/', include('mobile_5BC.foo.urls')),

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

(r'^admin/', include(admin.site.urls)),
(r'^$', front_page),
(r'^user/(\w+)/$', user_page),
(r'^login/$', 'django.contrib.auth.views.login'),
(r'^login/success/$', direct_to_template,
{'template': 'front_page'}),    
#(r'^accounts/login/$', 'django.contrib.auth.views.login'),
 (r'^logout/$', logout_page),
  (r'^media/(?P<path>.*)$', 'django.views.static.serve',
   {'document_root': MEDIA_ROOT}),
  (r'^register/$', register_page),
  (r'^register/success/$', redirect_to,
   {'url': '/login/'}),
  (r'^save/$', wine_add_page),
  (r'detail/(\w+)/', wine_detail_page),
  (r'wine_image/(\w+)/$', wine_image),    
  (r'wines/([^\s]+)/$', wine_results),
  (r'review/(\w+)/$', wine_review_page),
  (r'^accounts/', include('allauth.urls')),
  (r'^accounts/profile/', front_page),
)

and the passenger_wsgi.py

import sys, os
INTERP = '/home/MyUserName/local/bin/python' # Is my actual username
if sys.executable != INTERP:
   os.execl(INTERP, INTERP, *sys.argv)
sys.path.append(os.getcwd())
sys.path.append(os.getcwd()+'/fivebuckchuck')
os.environ['DJANGO_SETTINGS_MODULE'] = "fivebuckchuck.settings"
import django.core.handlers.wsgi
application = django.core.handlers.wsgi.WSGIHandler()


Issue ended up being Dreamhost writing an .htaccess file that had items for PHP in it, this subverted Django's URL reading scheme. Hope this might help other users.


You should check your apache config for unnecessary Redirect / Rewrite / Alias lines. Start out by removing all of them.


This may require some back and forth to solve. My initial guess is a problem with your passenger_wsgi.py file. If you are not using Apache in your dev environment (using Django's runserver for example) then you wouldn't hit this file and thus wouldn't have problems in dev. Make sure this line is pointing to the correct Django setting's file.

os.environ['DJANGO_SETTINGS_MODULE'] = "fivebuckchuck.settings"

http://5buckchuck.com/media/ gives me this error:

An error occurred importing your passenger_wsgi.py

(Past tense, you've changed something and now that URL gives a "Hello World!" Python message now. Now it's an ImportError with debug traceback. Heheh, okay I'll let this answer sit for a moment.)

This may be a longshot, but take a read of this. It's James Bennett on ways to setup and load settings for Django. You could try importing your settings and feeding it to setup_environ().

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜