def debug(request): """ In the case we work through docker's shared network we should add its IP inside INTERNAL_IPS and then pass processing to django's own debug function defined inside context_processors """ if settings.DEBUG: # automatically add REMOTE_IP which is docker's network gateway # into settings.INTERNAL_IPS remote = request.META['REMOTE_ADDR'] if remote not in settings.INTERNAL_IPS: settings.INTERNAL_IPS.append(remote) return context_processors.debug(request)
def debug(request): '''Return context variables that may be helpful for debugging. Extends :meth:`django.core.context_processors.debug` to include output from a secondary (esd) database. Runs the :meth:`django.core.context_processors.debug`; if the returned context indicates that debugging should be enabled and the ``esd`` database is configured, adds any queries made against the esd database to the ``sql_queries`` added to the context. ''' context_extras = context_processors.debug(request) context_extras['ENABLE_BETA_WARNING'] = getattr(settings, 'ENABLE_BETA_WARNING', False) if 'debug' in context_extras and context_extras['debug'] \ and 'esd' in settings.DATABASES: from django.db import connections esd_queries = connections['esd'].queries for q in esd_queries: q['db'] = 'esd' context_extras['sql_queries']().extend(esd_queries) return context_extras
def print_queries(context): return context_processors.debug(context['request'])