简体   繁体   中英

How to simulate HTTP error 500 in django?

I have set a HTML page 500.html in my main direcroty. It will show this page when HTML 500 Internal Server Error occurs.

How can I generate this error to check if it works?

I'm gussesing I should somehow raise exception of some sort.

How do I do that?

Try editing the urls.py as follows:

if settings.DEBUG:
    urlpatterns += patterns('',
        (r'^500/$', 'django.views.defaults.server_error'),
    )

Then try accessing the page as follows:

http://localhost/500

http://yoursite.com/500

The technical post webpages of this site follow the CC BY-SA 4.0 protocol. If you need to reprint, please indicate the site URL or the original address.Any question please contact:yoyou2525@163.com.

 
粤ICP备18138465号  © 2020-2024 STACKOOM.COM