[Answer]-Django-cms/Django SingleRelatedObjectDescriptor instead of object itself

1πŸ‘

βœ…

In your plugin you should access object fields via the instance argument to render, not self.model. Like this:

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 links_plugin.models import Section, SectionConfig

class LinksPlugin(CMSPluginBase):
    name = _("Links Tree Plugin")
    model = SectionConfig
    render_template = "links.html"
    cache = False

    def render(self, context, instance, placeholder):
        context['instance'] = instance
        context['Sobj'] = instance.sectionconfig
        return context

plugin_pool.register_plugin(LinksPlugin)
πŸ‘€ojii

Leave a comment