DJT

Creating a Custom Panel for the Django Debug Toolbar

Sometimes you work on stuff you don’t really control, eg. when interacting with some mysterious SOAP server accross the Internets, and you’d appreciate a little help from the Django ecosystem to ease debugging.

That’s — you guessed it — my case currently, and I really appreciated being able to create my own custom panel for adding specific debugging capabilities to the awesome Django Debug Toolbar.

Here’s how I did, learning mainly from the code of the panels shipping with the DJT. I’m supposing you have installed and configured the DJT in your project already.

First of all, create a panels.py module within one of your app (or wherever you want as it’s in your python path) and create a DebugPanel derivated class, like this:

from debug_toolbar.panels import DebugPanel
from django.template.loader import render_to_string
from django.utils.translation import ugettext_lazy as _


class MyUsefulDebugPanel(DebugPanel):
    name = 'MyUseful'
    has_content = True

    def nav_title(self):
        return _('Useful Infos')

    def title(self):
        return _('My Useful Debug Panel')

    def url(self):
        return ''

    def content(self):
        context = self.context.copy()
        context.update({
            'infos': [
                {'plop': 'plip'},
                {'plop': 'plup'},
            ],
        })
        return render_to_string('panels/my_useful_panel.html', context)

The debug panel class methods and code should be self-explanatory enough. Just note you have to create a template, here panels/my_useful_panel.html to be stored in your project templates directory, with this kind of contents:

<p>Hey, these are useful informations, I swear:</p>
<ul>
{% for info in infos %}
    <li>Plop is {{ info.plop}}</li>
{% endfor %}
</ul>

Now you have to register the new panel by adding its path to the DEBUG_TOOLBAR_PANELS tuple, in your settings.py (create it if it’s not there):

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',
    'my_app_name.panels.MyUsefulDebugPanel',
)

Of course it’s up to you to put really useful informations there, but here’s the result, tadaa:

Thanks for reading, happy ponying.

Corner Man

We know this photo is significant — used in the promo video and the pic of Callen with Arkady, shows him studying the image.

Been letting thoughts on the photo marinate for a few days and this is some theories floating around in my mind.

Same Tea house in the picture. So was this a meeting place for those who bore the Lenin coin? How long has Arkady owned the tea house?

Corner man, who conveniently has his back turned, want to bet he is suppose to be Callen’s father. Notice he has dark hair which is opposite of the man in the family film. So has he been hiding in plain sight?

The promised reveal. How “big” can it be? I can’t see the audience getting to meet the mysterious Reznikov yet. SB’s own statements see this event as something for further season’s. So what do we learn about Callen’s father this time? Not the promised hero? Released early from prison for good behavior or never was in prison. Another name, perhaps the Chernoff, K.(though I still see that as a Hetty alias)

Another reason I am stalling on Callen’s Father being revealed now, I don’t want DJT to play him. I think DJT is great actor, with a wide range and depth in his career but not right for the unknown father of Callen. He can be an uncle, which might be interesting. Callen having actual blood relations, who is not at all the man he portrays his self as and possibly involved with keeping his brother away from his son. Yes, great. Just not Callen’s father.

I want DJT to be for Hetty, one of the acquaintances mentioned from the past. Their interaction can lead to good sparring matches. Also tie him into the mole story that is dangling out there.(With that somehow linking the IA investigation on Deeks.)

Just not Reznikov, or whatever his name may be.

instagram

“How I Feel” #NxtUp #Music #Rap #DjT #Life #Truth #Dreams #Experience #Good #Bad #SoundsLikeDjT #HipHop (For more Gems, Follow me on here or on SoundCloud: David DjT Thenor

9

My darling love, the one I want to cuddle and lounge around with all day and the one I want to go on adventures with also. Absolutely everything I could possibly want and the one who continues to better himself and never gives up on me or us. I wouldn’t trade him for the world and I’m truly blessed to be able to fall asleep to every night and then wake up to knowing we’ll be together soon. I adore him endlessly, every single day, every single second.