Skip to content

Instantly share code, notes, and snippets.

@carlkibler
Created August 13, 2013 21:30
Show Gist options
  • Save carlkibler/6225886 to your computer and use it in GitHub Desktop.
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/
# 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