1đź‘Ť
âś…
i think best way is use logging and add some code to this
like
from django.db import connection
sql=connection.queries
and
doc = {
'record_hash': hash,
'level': record.level,
'channel': record.channel or u'',
'location': u'%s:%d' % (record.filename, record.lineno),
"message": record.msg,
'module': record.module or u'<unknown>',
'occurrence_count': 0,
'solved': False,
'app_id': app_id,
'sql': sql,
}
read more about this in http://docs.djangoproject.com/en/dev/topics/logging/
👤Mohammad Efazati
2đź‘Ť
I wouldn’t recommend modifying the runserver command, but…
django-devserver has a replacement for the manage.py runserver
command that allows extending the output to show any information you’re interested in.
The instructions on the page linked above show how to install, and near the bottom there is a “Building Modules” that shows an example for extending the output.
I’m not exactly sure what you’re looking to output, but maybe something like:
from devserver.modules import DevServerModule
class ViewNameModule(DevServerModule):
logger_name = 'view name module'
def process_view(self, request, view_func, view_args, view_kwargs):
self.logger.info('View name: %s' % '.'.join([view_func.__module__, view_func.func_name]))
👤meshantz
- [Django]-Django-allauth returns error "Reverse … with arguments '()' and keyword arguments '{}' not found"
- [Django]-Converting geometry point to lat/long in Geodjango app
- [Django]-Why does this Django form complain "this field is required" for an image field?
- [Django]-Django form to add item returning 'NoneType' object is not callable error
- [Django]-Django form: erorr passing model foreign into a form choice field
0đź‘Ť
Not the exactly the answer to your question, but I think django-debug-toolbar shows all the queries and many other useful information.
👤Myth
- [Django]-Postgresql django not sending password
- [Django]-Python Celery group() – TypeError: […] argument after ** must be a mapping, not long
- [Django]-Django TemplateDoesNotExist admin/login.html
Source:stackexchange.com