Reputation: 4930
I want edit out put of django runserver ... i want add now object address like apps.views.index
add all query in this request
how can change code for this setting?
Upvotes: 3
Views: 1856
Reputation: 4930
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/
Upvotes: 1
Reputation: 1626
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]))
Upvotes: 2
Reputation: 1602
Not the exactly the answer to your question, but I think django-debug-toolbar shows all the queries and many other useful information.
Upvotes: 0