django-debug-toolbar 与 django-cms 和 Django 1.3
尝试一起使用 django-debug-toolbar 和 django-cms 时,我不断遇到错误。
“MpttMeta 没有属性 'class'”
我感觉这与与 Django CMS 捆绑在一起的 Mptt 应用程序有关,但我不确定,而且我在一些项目中看到过这种情况但我很惊讶我在谷歌中找不到错误消息的直接点击,所以我想我应该在这里发布。
我尝试过使用最新发布版本的调试工具栏、开发分支以及 dcramer 的分支,但没有任何区别。我使用的是 Django 1.3 和 Django CMS 2.1.3。
有什么想法吗?
谢谢!
I keep hitting an error when trying to use django-debug-toolbar and django-cms together.
"MpttMeta has no attribute 'class'"
I have a feeling it's something to do with the Mptt app bundled with Django CMS, but I'm not sure, and I've seen this on a few projects but I'm surprised I can't find a direct hit for the error message in Google so I thought I'd post here.
I've tried using latest released version of debug toolbar, also the develop branch, and also dcramer's fork, but it's making no difference. I'm on Django 1.3 and Django CMS 2.1.3.
Any ideas?
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(4)
问题是 django-debug-toolbar 期望 MpttMeta 类需要是一个“新样式”类,这是一个相当简单的补丁(django-cms/publisher/mptt_support.py 中的第 33 行)。更改:
在
Django-CMS 2.1.3 中,他们仍然有自己的猴子补丁 mptt 与 Django-CMS 捆绑在一起。在下一个版本的Django-CMS中,将不再捆绑自己的mptt,而是依赖独立开发的包。
The problem is that django-debug-toolbar expects the MpttMeta class needs to be a 'new style' class, which is a fairly straightforward patch (line 33 in django-cms/publisher/mptt_support.py). Change:
to
In Django-CMS 2.1.3, they still have their own monkey-patched mptt bundled with Django-CMS. In the next release of Django-CMS will no longer bundle its own mptt and will instead rely on the independently developed package.
这可能是与 Django 1.3 相关的任何问题。
Django CMS 2.1.3 仅支持 1.2.X 分支: http ://docs.django-cms.org/en/2.1.3/getting_started/installation.html#requirements
Jonas Obrist,Django CMS 开发人员说"可能是以下版本的次要版本
2.1将添加官方1.3支持”
It could be any problem related to Django 1.3.
Django CMS 2.1.3 supports only 1.2.X branch: http://docs.django-cms.org/en/2.1.3/getting_started/installation.html#requirements
Jonas Obrist, Django CMS dev says "Maybe a minor version of
2.1 will add official 1.3 support"
或者你可以把它放在你的.... urls.py 中。不在 settings.py 中,因为项目将无法启动。
Or you can put this in yours .... urls.py for example. Not in settings.py because project will not start.
我相信这与 MPTTMeta 类加载到元类 (MPTTModelBase) 的方式有关,使其没有 class 属性。
Monkeypatch 修复是将有问题的语句包装在 django-debug-toolbar 中,如下所示:
这会稍微改变输出,显然
不是永久修复,但它可以让 debug-toolbar + django-cms 正常工作。
I believe this had to do with the way the MPTTMeta class is loaded into the metaclass (MPTTModelBase) making it not have a class attribute.
A monkeypatch fix is to wrap the offending statement in django-debug-toolbar like so:
This changes the output slightly to become
Clearly not a permanent fix, but it gets you the debug-toolbar + django-cms working.