Skip to main content

Rickrolling Django middleware to annoy potential hackers

Project description

A novel way of handling malicious requests within a Django application.


Install from PyPi (stable):

pip install django-rickroll

or Github (dev):

pip install -e git://

Add 'rickroll' to your INSTALLED_APPS and the following to your MIDDLEWARE_CLASSES:



Wherever you detect a hacking attempt, raise a HackingAttempt exception and the middleware will rickroll the offending user.

For example, in your

from rickroll.exceptions import HackingAttempt

def some_view(request):
    # ...
    if hacking_detected:
        raise HackingAttempt()

then the user in question will get redirected to The destination can be overridden using the setting RICKROLL_URL.


If your site ever gets penetration tested, the testing company will likely manipulate every request to your site where there are parameters being passed (query parameters, POST params, cookies etc). When you encounter a parameter which should be an integer but has value ../../../../../../etc/passwd, it’s not always clear what the “right” response should be. I thought it would be funny to rickroll.

Project details

Download files

Download the file for your platform. If you're not sure which to choose, learn more about installing packages.

Source Distribution

django-rickroll-0.1.1.tar.gz (2.7 kB view hashes)

Uploaded source

Supported by

AWS AWS Cloud computing Datadog Datadog Monitoring Facebook / Instagram Facebook / Instagram PSF Sponsor Fastly Fastly CDN Google Google Object Storage and Download Analytics Huawei Huawei PSF Sponsor Microsoft Microsoft PSF Sponsor NVIDIA NVIDIA PSF Sponsor Pingdom Pingdom Monitoring Salesforce Salesforce PSF Sponsor Sentry Sentry Error logging StatusPage StatusPage Status page