Django CMS用户无权添加插件

时间:2016-12-09 11:54:08

标签: django django-models django-templates django-admin django-cms

我有一个Django-CMS网站,我创建了一个文章模型来添加新闻,事件和其他材料。此模型有一个内容字段,它是一个PlaceholderField,因此用户可以为每篇文章添加所需的插件。问题是我创建了一个没有超级用户身份的用户,但给了他创建/编辑用户时出现的所有权限。但是该用户无法为此模型添加插件。他可以将插件添加到cms页面,但不能添加到此模型。我是否需要为此案例创建某种权限?我该怎么做?

我的模特:

class Articles(models.Model):

    objects = ArticlesManager()

    id = models.AutoField(db_column='ID', primary_key=True)

    sites = models.ManyToManyField(Site, verbose_name=_(u'Show in Sites'), related_name='articles_to_show')

    type = models.ForeignKey('Types', db_column='TYPE_ID',
                             related_name='type', verbose_name=_(u'Type'))

    content = PlaceholderField('ipp_article_content',
                               related_name='IPP_ARTICLE_CONTENT')

    class Meta:
        app_label = 'cms_ipportalegre'
        db_table = 'ipp_articles'
        verbose_name = _(u'Article')
        verbose_name_plural = _(u'Articles')
        permissions = (
            ("view_articles", _(u"Can view Articles")),
        )

在我的模板中:

<p>{% render_placeholder object.content language placeholder_language %}</p>

1 个答案:

答案 0 :(得分:0)

我发现了问题。我在admin.py中有一个ArticleAdmin和ArticleAdminForm的配置,我在其中定义了&#34;内容&#34;在排除字段中。

timestampdiff(HOUR, published_at, completed_at) as date_diff

当我从class ArticleAdminForm(ModelForm): class Meta: model = models.Articles exclude = ["title", "description", "content" , "creation_date", "site", "slug", "counter"] def __init__(self, *args, **kwargs): super(ArticleAdminForm, self).__init__(*args, **kwargs) class ArticleAdmin(PlaceholderAdminMixin, FrontendEditableAdminMixin, admin.ModelAdmin): form = ArticleAdminForm frontend_editable_fields = ("sites", "featured_image", "article_image", "title_pt", "title_en", "title_es", "title_fr") 移除content时,一切正常。