Commit 06c13144 by Harry Marr

Added example

parent c92cff03
#!/usr/bin/env python
from django.core.management import execute_manager
try:
import settings # Assumed to be in the same directory.
except ImportError:
import sys
sys.stderr.write("Error: Can't find the file 'settings.py' in the directory containing %r. It appears you've customized things.\nYou'll have to run django-admin.py, passing it your settings module.\n(If the file settings.py does indeed exist, it's causing an ImportError somehow.)\n" % __file__)
sys.exit(1)
import sys
sys.path.insert(0, '..')
if __name__ == "__main__":
execute_manager(settings)
import os
DEBUG = True
DATABASES = {
'default': {
'ENGINE': 'django.db.backends.sqlite3',
'NAME': 'example.db',
}
}
SECRET_KEY = 'u=0tir)ob&3%uw3h4&&$%!!kffw$h*!_ia46f)qz%2rxnkhak&'
MIDDLEWARE_CLASSES = (
'django.middleware.common.CommonMiddleware',
'debug_toolbar.middleware.DebugToolbarMiddleware',
)
TEMPLATE_LOADERS = (
'django.template.loaders.filesystem.load_template_source',
'django.template.loaders.app_directories.load_template_source',
)
TEMPLATE_DIRS = (
os.path.join(os.path.dirname(__file__), 'templates'),
)
INSTALLED_APPS = (
'debug_toolbar',
'debug_toolbar_mongo',
)
DEBUG_TOOLBAR_PANELS = (
'debug_toolbar.panels.version.VersionDebugPanel',
'debug_toolbar.panels.timer.TimerDebugPanel',
'debug_toolbar.panels.settings_vars.SettingsVarsDebugPanel',
'debug_toolbar.panels.headers.HeaderDebugPanel',
'debug_toolbar.panels.request_vars.RequestVarsDebugPanel',
'debug_toolbar.panels.template.TemplateDebugPanel',
'debug_toolbar.panels.sql.SQLDebugPanel',
'debug_toolbar.panels.signals.SignalDebugPanel',
'debug_toolbar.panels.logger.LoggingPanel',
'debug_toolbar_mongo.panel.MongoDebugPanel',
)
ROOT_URLCONF = 'example.urls'
INTERNAL_IPS = ('127.0.0.1',)
<html>
<head>
<title>Django Debug Toolbar Mongo Panel Example</title>
<style type="text/css">
font-family: Helvetica, freesans, Arial, sans-serif;
</style>
</head>
<body>
Bar on the right --&gt;
{% block content %}{% endblock %}
</body>
</html>
{% extends "base.html" %}
{% block content %}
{% endblock %}
from django.conf.urls.defaults import *
urlpatterns = patterns('',
url(r'^$', 'views.index', name='index'),
)
from django.http import HttpResponse
from django.core.urlresolvers import reverse
from django.shortcuts import render_to_response
import pymongo
conn = pymongo.Connection()
db = conn.debug_test
def index(request):
list(db.test.find({'name': 'test'}))
list(db.test.find({'name': 'test'}).skip(1))
db.test.find({'name': 'test'}).count()
db.test.find({'name': 'test'}).skip(1).count(with_limit_and_skip=True)
return render_to_response('index.html')
Markdown is supported
0% or
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment