Skip to main content
# django-misery

## Overview

A simple ban system for Django, that does nasty stuff to trolls wandering on your website.

Users banned the classical way are encouraged to bypass the ban by creating another account or changing their IP address.
A nastier and probably more effective way to do it is to use what is known as slowban, and errorban. This Django middleware implements those.

### Features

* slowing page generation for miserable users
* logging them out randomly
* send a 404 from time to time...
* ... or a 403...
* ... or even a blank page if you want
* last but not least, a wonderful ASP.NET error page made just for them

Hey, they deserved it!

### Pros:

* lightweight, designed not to slow down your website a single bit (from a non-miserable point of view, of course)
* supports both IPv4 and IPv6

### Cons:

* doesn't currently support masks. Yes, it can be handy against users having a botnet under their control or in case of a user having an IPv6 range, but the current implementation favors speed over features.

## Installation & configuration

To install the app, you can use PIP: `pip install django-misery`; then add `django_misery` to your INSTALLED_APPS setting, and `django_misery.middleware.miserize` to your MIDDLEWARE_CLASSES.

The following settings can be personnalized:

* `MISERY_SLOW_STRENGTH`: seconds that miserable users will have to wait _at least_ (maximum twice longer) (default: 6)
* `MISERY_LOGOUT_PROBABILITY`: **percentage** of probability a user will be disconnected (default: 10)
* `MISERY_403_PROBABILITY`: same for 403 (default: 10)
* `MISERY_404_PROBABILITY`: I'm gonna let you guess for this one (default: 10)
* `MISERY_WHITE_SCREEN_PROBABILITY`: same for a nice, 100% pure white (not a single subpixel in the viewport will be off, I promise) (default: 10)
* `MISERY_ASP_ERROR_PROBABILITY`: a free bonus for ASP lovers (and I'm sure there are plenty around here), the template renders just great. Oh and: to make it even more beautiful, it's in French (default: 10). Quick preview:

![ASP error overview](http://img11.hostingpics.net/pics/560987ASPerror.png)

By default, miserable users have approximately a 50-50 chance to see the real page. They won't stay long, I promise.

## Miscellaneous

Inspired by the [Drupal Misery module](http://drupal.org/project/misery), see also ["Suspension, Ban or Hellban?"](http://www.codinghorror.com/blog/2011/06/suspension-ban-or-hellban.html) for hellbanning.

Metadata

Release files for django-misery 0.0.3

For a detailed explanation of source distributions (sdists) and built distributions (wheels), please see the package formats documentation.

Source distribution (sdist)

Source distribution for django-misery 0.0.3
File Size Uploaded Provenance Actions
django-misery-0.0.3.tar.gz 5.9 kB Without provenance Details for django-misery-0.0.3.tar.gz

Release files / django-misery-0.0.3.tar.gz

Download URL django-misery-0.0.3.tar.gz
Size 5.9 kB
Tags Source
SHA-256 checksum
How to use checksums
a896aeb08cb5a57e9deb177269dacf26cbbb6ee9bc417d9904e3ddd61a6201d8
BLAKE2b-256 checksum
How to use checksums
b97c7d644fe12d64cea404a239aa62b1713e53dc0808e19595d7763c5a78d390
Upload date
Uploaded using Trusted Publishing?
What is trusted publishing?
No

Security for django-misery 0.0.3

Provenance

Provenance describes where a file came from. On PyPI, provenance is shared via attestations, which provide a verifiable record of the build or publishing details. View details, limitations and caveats.

No provenance found

None of the files in this release were uploaded with provenance metadata.

A note on package security

PyPI is a repository for distributing packages, not a service for auditing them. While third-party security researchers and our staff do their best to detect and remove malicious packages, PyPI cannot guarantee the quality, security or suitability of any given package.

To learn more about protecting yourself from malicious actors, visit our package security documentation.

Release history Release notifications | RSS feed

This release

0.0.3 This release

1 release file No provenance

Anthropic, PBC Visionary sponsor Bloomberg Visionary sponsor Hudson River Trading Visionary sponsor Meta Visionary sponsor NVIDIA Visionary sponsor Microsoft Sustainability sponsor Depot Continuous Integration AWS Cloud computing and Security Sponsor Datadog Monitoring Fastly CDN Google Download Analytics Sentry Error logging StatusPage Status page