Created
August 13, 2013 21:30
-
-
Save carlkibler/6225886 to your computer and use it in GitHub Desktop.
Useful code for Django Debug Toolbar. it turns the INTERNAL_IPS list into a list of pattern matches. Wildcards are allowed for whatever specificity you want. Cleanedup form original inspiration: http://dancarroll.org/blog/2011/01/debugging-django-dev-server/
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
# Insert this into settings.py, or move and adapt to wherever you need. | |
if DEBUG: | |
from fnmatch import fnmatch | |
class pattern_list(list): | |
def __contains__(self, key): | |
for pattern in self: | |
if fnmatch(key, pattern): return True | |
return False | |
INTERNAL_IPS = pattern_list(['127.0.0.1', '192.168.*.*']) | |
else: | |
INTERNAL_IPS = ('127.0.0.1', ) |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment