我在 django-cms 上编写了一个自定义插件并添加了一个占位符字段。在占位符上添加该插件后,我尝试使用前端编辑在占位符字段中添加插件,它会抛出:
关于前端编辑
Failed to load resource: the server responded with a status of 404 (NOT FOUND)
http://localhost:8000/es/admin/cms/page/add-plugin/
在控制台上出现
"POST /es/admin/cms/page/add-plugin/ HTTP/1.1" 404 1620
当我尝试使用管理界面或前端编辑编辑放置在页面中的自定义插件时
TypeError at /es/admin/cms/page/4/edit-plugin/14/
<lambda>() takes exactly 1 argument (2 given)
Request Method: GET
Request URL: http://localhost:8000/es/admin/cms/page/4/edit-plugin/14/
Django Version: 1.5.1
Exception Type: TypeError
Exception Value:
<lambda>() takes exactly 1 argument (2 given)
Exception Location: /home/ed/Envs/django/local/lib/python2.7/site-packages/cms/forms/widgets.py in render, line 201
Python Executable: /home/ed/Envs/django/mh/../bin/python
我的插件代码如下所示
模型.py
from cms.models.pluginmodel import CMSPlugin
from cms.models.fields import PlaceholderField
from django.db import models
# Create your models here.
class Item(CMSPlugin):
title = models.CharField(max_length=100, default="Item Name",verbose_name=u'Titulo')
description = PlaceholderField('Item_Description')
image = models.ImageField(upload_to="uploads/images/",verbose_name=u'Imagen')
imageDescription = models.CharField(max_length=50,default="Image",verbose_name=u'Descripcion de la imagen')
管理员.py
from django.contrib import admin
from cms.admin.placeholderadmin import PlaceholderAdmin
from projects.models import Item
admin.site.register(Item, PlaceholderAdmin)
cms_plugins.py
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
from cms.models.pluginmodel import CMSPlugin
from django.utils.translation import ugettext_lazy as _
from models import Item
class ItemPlugin(CMSPluginBase):
model = Item
name = "Item Plugin"
render_template = "item_plugin.html"
def render(self, context, instance, placeholder):
context['instance'] = instance
return context
#Registers the plugin
plugin_pool.register_plugin(ItemPlugin)
版本
我目前正在使用
Django-cms: 2.2
Django: 1.5.1
Linux: 12.04 LTS
请我想知道如何在占位符字段中放置一个插件,而不会出现那个烦人的错误。提前致谢