'internal' if request.META.get('REMOTE_ADDR') in settings.INTERNAL_IPS else 'EXTERNAL'

Much easier to parse that way, and recommended by van Rossums everywhere.