Dark Launch

This is a Dark Launch.

Django Show the Raw SQL Query Running

To see the raw SQL queries Django is running, do the following:

In your settings file (typically settings.py), ensure DEBUG is set to True

Python
DEBUG = True

Then import connection from django.db and print connection.queries

Python
from django.db import connection
from pprint import pprint
pprint(connection.queries)

If your queries are slowing you down, look into using select_related() to follow foreign keys

PHP Remove all but allowed characters or disallowed chars

The following will remove all characters but those allowed.

PHP
$str = preg_replace('@[^a-zA-Z0-9_:;\(\)\?\|\&=!<>+*/\%-]@', '', $str);