On 20/11/2011 07:56 πμ, Ricardo F. Teixeira wrote:
Hello everybody!

I'm having a strange error.
I already searched for this error and there's quite a lot of
discussion about it. But I didn't find a proper answer that fits me.
So... when I set DEBUG to True and access an invalid URL Django
returns me a 404 error page, but if I set DEBUG to False it gives me
an 500...

Firstly I thought it was something wrong with my project so I started
a new one, with only the following basics options.
I can assure you that I only edit those 3 files (views.py, urls.py and
settings.py).

In settings.py I only change from DEGUG=True to DEBUG=False.

ricardo@maggie:~/ola $ ls
__init__.py  __init__.pyc manage.py    settings.py  settings.pyc
urls.py      urls.pyc     views.py     views.pyc

ricardo@maggie:~/ola $ cat urls.py
from django.conf.urls.defaults import patterns, include, url

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

urlpatterns = patterns('',
     # Examples:
     url(r'^$', 'ola.views.home', name='home'),
     # url(r'^ola/', include('ola.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)),
)
ricardo@maggie:~/ola $ cat views.py
from django.http import HttpResponseNotFound

def home(request):
        return HttpResponseNotFound()

ricardo@maggie:~/ola $ python manage.py runserver
Validating models...

0 errors found
Django version 1.3.1, using settings 'ola.settings'
Development server is running at http://127.0.0.1:8000/
Quit the server with CONTROL-C.
[19/Nov/2011 23:53:21] "GET / HTTP/1.1" 404 0
Traceback (most recent call last):
   File "/Library/Python/2.7/site-packages/django/core/servers/
basehttp.py", line 283, in run
     self.result = application(self.environ, self.start_response)
   File "/Library/Python/2.7/site-packages/django/core/handlers/
wsgi.py", line 272, in __call__
     response = self.get_response(request)
   File "/Library/Python/2.7/site-packages/django/core/handlers/
base.py", line 153, in get_response
     response = self.handle_uncaught_exception(request, resolver,
sys.exc_info())
   File "/Library/Python/2.7/site-packages/django/core/handlers/
base.py", line 218, in handle_uncaught_exception
     return callback(request, **param_dict)
   File "/Library/Python/2.7/site-packages/django/utils/decorators.py",
line 93, in _wrapped_view
     response = view_func(request, *args, **kwargs)
   File "/Library/Python/2.7/site-packages/django/views/defaults.py",
line 30, in server_error
     t = loader.get_template(template_name) # You need to create a
500.html template.
   File "/Library/Python/2.7/site-packages/django/template/loader.py",
line 157, in get_template
     template, origin = find_template(template_name)
   File "/Library/Python/2.7/site-packages/django/template/loader.py",
line 138, in find_template
     raise TemplateDoesNotExist(name)
TemplateDoesNotExist: 500.html

[19/Nov/2011 23:53:48] "GET /GIVE_ME_400 HTTP/1.1" 500 1314
Traceback (most recent call last):
   File "/Library/Python/2.7/site-packages/django/core/servers/
basehttp.py", line 283, in run
     self.result = application(self.environ, self.start_response)
   File "/Library/Python/2.7/site-packages/django/core/handlers/
wsgi.py", line 272, in __call__
     response = self.get_response(request)
   File "/Library/Python/2.7/site-packages/django/core/handlers/
base.py", line 153, in get_response
     response = self.handle_uncaught_exception(request, resolver,
sys.exc_info())
   File "/Library/Python/2.7/site-packages/django/core/handlers/
base.py", line 218, in handle_uncaught_exception
     return callback(request, **param_dict)
   File "/Library/Python/2.7/site-packages/django/utils/decorators.py",
line 93, in _wrapped_view
     response = view_func(request, *args, **kwargs)
   File "/Library/Python/2.7/site-packages/django/views/defaults.py",
line 30, in server_error
     t = loader.get_template(template_name) # You need to create a
500.html template.
   File "/Library/Python/2.7/site-packages/django/template/loader.py",
line 157, in get_template
     template, origin = find_template(template_name)
   File "/Library/Python/2.7/site-packages/django/template/loader.py",
line 138, in find_template
     raise TemplateDoesNotExist(name)
TemplateDoesNotExist: 500.html

Thank you for your time.

Best regards,

Ricardo F. Teixeira

If the template exists, then
it could easily be a directory or file permission error.
I have seen the same in my installation a number of times :)
Check out the paths and the permissions

--
 --------------------------------------------------------------
                   Nick Apostolakis
              e-mail: nicka...@oncrete.gr
         Web Site: http://nick.oncrete.gr
 --------------------------------------------------------------


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to django-users@googlegroups.com.
To unsubscribe from this group, send email to 
django-users+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to