[PYTHON] Volume of creating and publishing django-malice, a django application for causing HTTP 40X errors

In a development environment (DEBUG = True), django will display an error screen with a familiar and useful stack trace if an error occurs on the view.

However, in the case of a production environment, an email indicating that there was an error is sent to the email address set in ADMINS.

Also, if you are using slack_log_handler, the content of the error will be sent to slack.

I created django-malice because if something works after an error, I have to check it correctly.

About django-malice

--Provides a View to intentionally raise the following error

It also provides a page that returns HTTP 200 OK to check the normal system (HeartBeat, etc.).

django-malice (GitHub Repository)

motivation

――It is troublesome to prepare a View to raise an error intentionally to check the following. Then make and distribute. --I want to check if the error report is sent correctly --I want to check if the operation triggered by logging or error is driven correctly.

How to install django-malice

  1. Install the following with pip
$ pip install django-malice
  1. Add the following to INSTALLED_APPS
INSTALLED_APPS = [
    ...
    "malice",
]
  1. Add the following to urls.py specified in the project ROOT_URL_CONF
url(r'^malice/', include('malice.urls', namespace='malice')),

Note: In a production environment, it is safer to change the URL to a string that the attacker cannot predict.

Example:

view_urlpatterns = [
    ...
    url(r'^all-your-error-are-belong-to-us-2101/', include('malice.urls', namespace='malice')),
    ...
]
  1. Runserver and open the following URL in your browser
$ ./manage.py runserver 0.0.0.0:8000

Make sure that URLs other than 200 return an error.

If DEBUG is True, no mail will be sent to ADMINS, so set the DEBUG flag to False and make sure that an error report is sent.

Regarding development

This application built tests on circleci, packaged it, and distributed it on Pypi throughout the django meetup time.

Thanks to BeProud's https://twitter.com/hirokiky and https://twitter.com/shimizukawa for hosting the event here!

If you have time, why don't you join django meetup!

Recommended Posts

Volume of creating and publishing django-malice, a django application for causing HTTP 40X errors
Explanation of creating an application for displaying images and drawing with Python
Commands for creating a new django project
[Personal development] Story of creating an application for artists with SPA with Django REST Framework and Vue-Cli [DRF + Vue.js]
Try creating a web application with Vue.js and Django (Mac)-(1) Environment construction, application creation
A collection of resources that may be useful for creating and expanding dotfiles
Procedure for creating an application with Django with Pycharm ~ Preparation ~
The story of creating a "spirit and time chat room" exclusively for engineers in the company