2014-10-26 116 views
0

請幫助修復錯誤如何擴展插件?

在django cms中添加了插件民意調查。然後嘗試擴展它爲這個tutorial。由於我的目錄結構看起來像是like

的問題是,當你嘗試運行網站控制檯顯示以下錯誤消息:

Traceback (most recent call last): 
    File "/usr/lib/python2.7/wsgiref/handlers.py", line 85, in run 
    self.result = application(self.environ, self.start_response) 
    File "/home/kalinins/.virtualenvs/blogik4/local/lib/python2.7/site-packages/django/contrib/staticfiles/handlers.py", line 67, in __call__ 
    return self.application(environ, start_response) 
    File "/home/kalinins/.virtualenvs/blogik4/local/lib/python2.7/site-packages/django/core/handlers/wsgi.py", line 187, in __call__ 
    self.load_middleware() 
    File "/home/kalinins/.virtualenvs/blogik4/local/lib/python2.7/site-packages/django/core/handlers/base.py", line 47, in load_middleware 
    mw_instance = mw_class() 
    File "/home/kalinins/.virtualenvs/blogik4/local/lib/python2.7/site-packages/django/middleware/locale.py", line 24, in __init__ 
    for url_pattern in get_resolver(None).url_patterns: 
    File "/home/kalinins/.virtualenvs/blogik4/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 365, in url_patterns 
    patterns = getattr(self.urlconf_module, "urlpatterns", self.urlconf_module) 
    File "/home/kalinins/.virtualenvs/blogik4/local/lib/python2.7/site-packages/django/core/urlresolvers.py", line 360, in urlconf_module 
    self._urlconf_module = import_module(self.urlconf_name) 
    File "/home/kalinins/.virtualenvs/blogik4/local/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module 
    __import__(name) 
    File "/home/kalinins/.virtualenvs/blogik4/blogik4/blogik4/urls.py", line 8, in <module> 
    admin.autodiscover() 
    File "/home/kalinins/.virtualenvs/blogik4/local/lib/python2.7/site-packages/django/contrib/admin/__init__.py", line 29, in autodiscover 
    import_module('%s.admin' % app) 
    File "/home/kalinins/.virtualenvs/blogik4/local/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module 
    __import__(name) 
    File "/home/kalinins/.virtualenvs/blogik4/local/lib/python2.7/site-packages/cms/admin/__init__.py", line 11, in <module> 
    plugin_pool.plugin_pool.discover_plugins() 
    File "/home/kalinins/.virtualenvs/blogik4/local/lib/python2.7/site-packages/cms/plugin_pool.py", line 36, in discover_plugins 
    load('cms_plugins') 
    File "/home/kalinins/.virtualenvs/blogik4/local/lib/python2.7/site-packages/cms/utils/django_load.py", line 56, in load 
    get_module(app, modname, verbose, failfast) 
    File "/home/kalinins/.virtualenvs/blogik4/local/lib/python2.7/site-packages/cms/utils/django_load.py", line 40, in get_module 
    module = import_module(module_name) 
    File "/home/kalinins/.virtualenvs/blogik4/local/lib/python2.7/site-packages/django/utils/importlib.py", line 40, in import_module 
    __import__(name) 
    File "/home/kalinins/.virtualenvs/blogik4/blogik4/djangocms_polls/cms_plugins.py", line 17, in <module> 
    plugin_pool.register_plugin(CMSPollPlugin) # register the plugin 
    File "/home/kalinins/.virtualenvs/blogik4/local/lib/python2.7/site-packages/cms/plugin_pool.py", line 87, in register_plugin 
    % (plugin, template) 
ImproperlyConfigured: CMS Plugins must define a render template (<class 'djangocms_polls.cms_plugins.CMSPollPlugin'>) that exists: djangocms_polls/poll_plugin.html 

回答

0

你需要在你的模板文件夾

在這種情況下創建一個HTML模板您註冊的模板文件夾中的模板poll_plugin.htmldjangocms_polls

... 
render_template = "djangocms_polls/poll_plugin.html" 
.. 

這個模板必須存在,以使CMS插件可以正常工作,這是插件呈現上下文數據的模板。

0

你需要在你的設置來定義的模板列表,在CMS_TEMPLATES變量。

而且...把你現有的模板放到djangocms_polls子目錄下,所以它會在djangocms_polls/templates/djangocms_polls/poll_plugin.html