Django debug toolbar: no attribute 'app_label'
brstra opened this issue · 9 comments
Hey!
When I'm using QuerySetSequence with debug turned on, Django debug toolbar complains that:
AttributeError at /
class _meta has no attribute 'app_label'
env/local/lib/python2.7/site-packages/debug_toolbar/panels/templates/panel.py in _store_template_info
value.model._meta.app_label, value.model.__name__)
I've added app_label = 'QuerySetSequenceModel'
to _meta class of QuerySetSequenceModel and it works. But maybe there is a better approach.
@brstra That sounds like it's likely the correct solution, what versions of Django/Django-Debug-Toolbar are you using?
Ideally I'd like to make QuerySetSequence
into more of a "real" model, but that's a excessive amount of work without significant benefits.
I'm using Django(1.9.5) and Django Debug Toolbar (1.4)
Interesting, I'm not seeing this with Django 1.9.5 and Django Debug Toolbar 1.4. Can you give more specific steps to reproduce the issue? (Does it happen on page load? When clicking a certain panel? Are you seeing a warning? An error?)
Would you be interested in putting up a pull request with the fix? Thanks!
Hmm... As it turns out - it's quite tricky to repeat.
It throws an exception on page load. It happens only in one specific place of my project, which is absolutely trivial at my point of view. And I can't figure out at a glance what exactly causes this error.
I'll investigate it more and make a pull request after.
Sounds good! Thanks for the bug report. 👍
Looks like at least some of the panels use it, I'm not 100% sure why it would happen, but that's OK.
Yep, that fixes the issue.
Probably, I need deeper understanding of Django and DjDT to understand why it happens.
For now I can tell you that it was happening while I was calling render shortcut in Django. And if there was QuerySetSequency object in the context I've seen that error. Otherwise, if I've converted the object into the list, or wrapped it with Pagination for example, everything worked smoothly.
Awesome. 👍 I just pushed 0.6 to pypi with this and a couple other minor changes.