[英]Overriding get_urls() for a Django CMS plugin
I'm working with a custom plugin using Django-CMS 3.0.13: 我正在使用Django-CMS 3.0.13使用自定义插件:
class PromoPlugin(CMSPluginBase):
. . .
def get_urls(self):
print 'here' # <-- NEVER CALLED
return super(CMSPluginBase, self).get_urls()
and trying to override get_urls()
but my override is never called . 并尝试覆盖get_urls()
但从未调用我的覆盖。 CMSPluginBase
inherits from ModelAdmin
(reference) ... what am I overlooking? CMSPluginBase
继承自ModelAdmin
(参考) ...我忽略了什么?
So, after some research, the actual problem that's happening is that the PlaceholderAdminMixin's edit_plugin url is stepping on another mixin's patterns, specifically those of django-genericadmin . 因此,在进行了一些研究之后, 实际发生的问题是PlaceholderAdminMixin的edit_plugin url正在使用另一种mixin的模式,特别是django- genericadmin的模式。
I added a url pattern exactly matching the pattern that was being stepped on to my PromoPlugin
class, but the pattern is probably registered too late to override the edit_plugin
pattern. 我添加了一个网址模式,该网址模式与PromoPlugin
类上踩到的模式完全匹配,但是该模式可能注册得太晚,无法覆盖edit_plugin
模式。 So, it looks like I'll be tweaking django-genericadmin's URLs. 因此,看起来我将调整django-genericadmin的URL。
I'm marking this answer as accepted since it's the correct way to augment a Plugin's URL patterns. 我将此答案标记为已接受,因为这是扩充插件URL模式的正确方法。
CMSPluginBase
subclasses ModelAdmin
, but is hooked into cms.plugin_pool.PluginPool
, not an admin site. CMSPluginBase
子类ModelAdmin
,但勾搭成cms.plugin_pool.PluginPool
,而不是一个管理站点。 Therefore not all APIs in ModelAdmin
are used. 因此,并非使用ModelAdmin
中的所有API。
However since 3.0 can use get_plugin_urls
API. 但是,由于3.0可以使用get_plugin_urls
API。
声明:本站的技术帖子网页,遵循CC BY-SA 4.0协议,如果您需要转载,请注明本站网址或者原文地址。任何问题请咨询:yoyou2525@163.com.