Django 1.1 returns 500 instead of 404 in non-debug mode

522 views
Skip to first unread message

prabhu S

unread,
Jul 30, 2009, 8:40:36 AM7/30/09
to Django users
Hi All,

I am not noticing a weird issue in django 1.1. When DEBUG is true in
settings and if I try a non-existent url, django shows me a friendly
404 page. Now I create 404.html and 500.html and place this in
templates directory. Then If I turn off debug and try a non-existent
url, I expect to see my 404 html. Instead django shows me 500.html.

Infact, even in development I see 500 error codes for missing css,
images and js.

Is anyone else noticing the same issue? Am I missing something?

Regards,
Prabhu

Karen Tracey

unread,
Jul 30, 2009, 9:25:25 AM7/30/09
to django...@googlegroups.com

I cannot recreate this.  Are you absolutely sure everything is set so that your 404.html is being found by the server?

Karen

prabhu S

unread,
Jul 30, 2009, 1:32:59 PM7/30/09
to Django users
Hi Karen,

Thanks for replying. I have put my 404.html in the same place as that
of 500.html. To make sure, I even copy pasted 500.html and changed the
error message text alone.

Here is an output from the django development server, when I tried to
access "sdfsa" (Invalid url)

[30/Jul/2009 18:25:45] "GET /admin/clienty/sdfsa HTTP/1.1" 500 1387
[30/Jul/2009 18:25:45] "GET /scripts/jquery-1.3.2.min.js HTTP/1.1" 500
1387
[30/Jul/2009 18:25:46] "GET /css/style.css HTTP/1.1" 500 1387

I have the sources online at http://github.com/prabhu/invoicy. I would
appreciate if you can take a look at settings.py and let me know if
something is obvious.

Thanks & Regards,
Prabhu

On Jul 30, 2:25 pm, Karen Tracey <kmtra...@gmail.com> wrote:

Luke Seelenbinder

unread,
Jul 30, 2009, 1:46:28 PM7/30/09
to django...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1

Hey, I think I located your problem.

In file invoicy / guidy / urls.py

You should change the first url pattern to read:
url(r'^/$', 'guidy_default', name='guidy-default'),
instead of:
url(r'^$', 'guidy_default', name='guidy-default'),

That should fix your problem. What is actually happening is you are
raising 500s on 404s. That's why the 404 error page is not showing.

Luke
luke.see...@gmail.com

"I [may] disapprove of what you say, but I will defend to the death your
right to say it." -- Voltaire
-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.9 (GNU/Linux)

iEYEARECAAYFAkpx3HAACgkQXQrGVCncjPyTCACfR6jyWAfXScSgM9STXKN5nksa
zRYAoJv2zvJnLpI47kuuArFS+tO5X6MW
=7wa6
-----END PGP SIGNATURE-----

prabhu S

unread,
Jul 30, 2009, 7:41:14 PM7/30/09
to Django users
Hi Luke,

Thanks for your email. The particular source is already fine with
no /. I also tried adding slash assuming you swapped the particular
line in your email.

Can you give another shot and let me know if you can spot something?

Regards,
Prabhu

On Jul 30, 6:46 pm, Luke Seelenbinder <luke.seelenbin...@gmail.com>
wrote:
> -----BEGIN PGP SIGNED MESSAGE-----
> Hash: SHA1
>
> Hey, I think I located your problem.
>
> In file invoicy / guidy / urls.py
>
> You should change the first url pattern to read:
> url(r'^/$', 'guidy_default', name='guidy-default'),
> instead of:
> url(r'^$', 'guidy_default', name='guidy-default'),
>
> That should fix your problem. What is actually happening is you are
> raising 500s on 404s. That's why the 404 error page is not showing.
>
> Luke
> luke.seelenbin...@gmail.com
>
> "I [may] disapprove of what you say, but I will defend to the death your
> right to say it." -- Voltaire
>
>
>
>
>
> prabhu S wrote:
> > Hi Karen,
>
> > Thanks for replying. I have put my 404.html in the same place as that
> > of500.html. To make sure, I even copy pasted500.html and changed the
> > error message text alone.
>
> > Here is an output from the django development server, when I tried to
> > access "sdfsa" (Invalid url)
>
> > [30/Jul/2009 18:25:45] "GET /admin/clienty/sdfsa HTTP/1.1"5001387
> > [30/Jul/2009 18:25:45] "GET /scripts/jquery-1.3.2.min.js HTTP/1.1"500
> > 1387
> > [30/Jul/2009 18:25:46] "GET /css/style.css HTTP/1.1"5001387
>
> > I have the sources online athttp://github.com/prabhu/invoicy. I would
> > appreciate if you can take a look at settings.py and let me know if
> > something is obvious.
>
> > Thanks & Regards,
> > Prabhu
>
> > On Jul 30, 2:25 pm, Karen Tracey <kmtra...@gmail.com> wrote:
> >> On Thu, Jul 30, 2009 at 8:40 AM, prabhu S <prabhu...@gmail.com> wrote:
>
> >>> Hi All,
> >>> I am not noticing a weird issue in django 1.1. When DEBUG is true in
> >>> settings and if I try a non-existent url, django shows me a friendly
> >>> 404 page. Now I create 404.html and500.html and place this in
> >>> templates directory. Then If I turn off debug and try a non-existent
> >>> url, I expect to see my 404 html. Instead django shows me500.html.
> >>> Infact, even in development I see500error codes for missing css,

Luke Seelenbinder

unread,
Jul 30, 2009, 9:44:17 PM7/30/09
to django...@googlegroups.com
-----BEGIN PGP SIGNED MESSAGE-----
Hash: SHA1


Prabhu,

Let's establish the reason the 404.html doesn't show on a supposed 404
error; that is because every single request on the output you posted a
little while ago from the server is responded with a 500 error.
Something is fouled up with the views, or somewhere in the server process.

I'll look through and see if I can spot anything.

Good luck!

Luke
luke.see...@gmail.com
iEYEARECAAYFAkpyTG0ACgkQXQrGVCncjPz94gCcCkyRaKjRdf11QcCU1x8qnRXp
lPsAoIjA42jV5QHx/Vrs5pUje+JAnL88
=jGM0
-----END PGP SIGNATURE-----
Reply all
Reply to author
Forward
0 new messages