node13h / django-debug-toolbar-template-profiler

Displays template rendering time on the timeline
Other
72 stars 14 forks source link

JavaScript to highlight timeline item is not working #22

Open jnns opened 2 years ago

jnns commented 2 years ago

I noticed that, when opening the panel, a request is made to /<page>/static/js/template_profiler.js and it returns with a 404.

Using the static helper from contrib.staticfiles makes the panel find the javascript file:

from django.templatetags.static import static

class TemplateProfilerPanel(Panel):
    @property
    def scripts(self):
        return [static("js/template_profiler.js")]

But now another problem arises: jQuery is not guaranteed to be available.

We could get around using JavaScript and jQuery altogether by adding a small CSS snippet to the panel's template:

<style>
  .timeline_item:hover {
    border: red 0.1px solid !important;
  }
</style>

Please let me know what you think about this approach. I can submit a pull request if you like.