Add tip on how to display the Django Debug Toolbar to the docs
This commit is contained in:
Родитель
e0c7ebaf78
Коммит
8cbc0db18e
|
@ -109,3 +109,13 @@ class TestNoAddonsMiddleware(amo.tests.TestCase):
|
|||
self.assertRaises(http.Http404, self.process, 'some.addons')
|
||||
self.assertRaises(http.Http404, self.process, 'some.addons.thingy')
|
||||
assert not self.process('something.else')
|
||||
|
||||
|
||||
class TestNoDjangoDebugToolbar(amo.tests.TestCase):
|
||||
"""Make sure the Django Debug Toolbar isn't available when DEBUG=False."""
|
||||
|
||||
def test_no_django_debug_toolbar(self):
|
||||
with self.settings(DEBUG=False):
|
||||
res = self.client.get(reverse('home'), follow=True)
|
||||
assert 'djDebug' not in res.content
|
||||
assert 'debug_toolbar' not in res.content
|
||||
|
|
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 58 KiB |
Двоичный файл не отображается.
После Ширина: | Высота: | Размер: 45 KiB |
|
@ -46,5 +46,25 @@ All being well it should look like this:
|
|||
.. image:: /screenshots/docker-ipdb.png
|
||||
|
||||
|
||||
Using the Django Debug Toolbar
|
||||
------------------------------
|
||||
|
||||
The `Django Debug Toolbar`_ is very powerful and useful when viewing pages from
|
||||
the website, to check the view used, its parameters, the SQL queries, the
|
||||
templates rendered and their context...
|
||||
|
||||
It should be enabled local development as long as ``settings.DEBUG`` is set to
|
||||
``True`` (which it is by default).
|
||||
|
||||
All being well it should look like this at the top-right of any web page on
|
||||
olympia:
|
||||
|
||||
.. image:: /screenshots/django-debug-toolbar.png
|
||||
|
||||
If clicked, it looks like:
|
||||
|
||||
.. image:: /screenshots/django-debug-toolbar-expanded.png
|
||||
|
||||
.. _ipdb: https://pypi.python.org/pypi/ipdb
|
||||
.. _docker-utils: https://pypi.python.org/pypi/docker-utils
|
||||
.. _Django Debug Toolbar: http://django-debug-toolbar.readthedocs.org/en/1.3.2/index.html
|
||||
|
|
|
@ -2,6 +2,6 @@
|
|||
-r docs.txt
|
||||
-r flake8.txt
|
||||
|
||||
django-debug-toolbar==1.2
|
||||
django-debug-toolbar==1.3.2
|
||||
django-fixture-magic==0.0.4
|
||||
sqlparse==0.1.14
|
||||
|
|
21
settings.py
21
settings.py
|
@ -79,6 +79,27 @@ TASK_USER_ID = 10968
|
|||
# Set to True if we're allowed to use X-SENDFILE.
|
||||
XSENDFILE = False
|
||||
|
||||
# Enable the Django Debug Toolbar for local dev.
|
||||
INSTALLED_APPS += (
|
||||
'debug_toolbar',
|
||||
)
|
||||
DEBUG_TOOLBAR_PATCH_SETTINGS = False # Prevent DDT from patching the settings.
|
||||
|
||||
MIDDLEWARE_CLASSES += ('debug_toolbar.middleware.DebugToolbarMiddleware',)
|
||||
|
||||
|
||||
def show_toolbar_callback(request):
|
||||
"""Callback used by the Django Debug Toolbar to decide when to display."""
|
||||
# We want to make sure to have the DEBUG value at runtime, not the one we
|
||||
# have in this specific settings file.
|
||||
from django.conf import settings
|
||||
return settings.DEBUG
|
||||
|
||||
|
||||
DEBUG_TOOLBAR_CONFIG = {
|
||||
"SHOW_TOOLBAR_CALLBACK": "settings.show_toolbar_callback",
|
||||
}
|
||||
|
||||
# If you have settings you want to overload, put them in a local_settings.py.
|
||||
try:
|
||||
from local_settings import * # noqa
|
||||
|
|
Загрузка…
Ссылка в новой задаче