I have written the following cms plugin. With this a user can add a connection from one news entry to a project.
cms_plugins.py:
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
class CMSProjectPlugin(CMSPluginBase):
model = ProjectPlugin
name = _("Project")
render_template = "CMSProjectPlugin.html"
def render(self, context, instance, placeholder):
context.update({
'project':instance.project,
'object':instance,
'placeholder':placeholder
})
return context
plugin_pool.register_plugin(CMSProjectPlugin)
Models:
from django.db import models
from cms.models.fields import PlaceholderField
class Project(models.Model):
title=models.CharField(_('Title'),max_length=250)
slug = AutoSlugField(populate_from='title')
class ProjectPlugin(CMSPlugin):
project = models.ForeignKey(Project)
class NewsEntry(models.Model):
title=models.CharField(_('Title'),max_length=250)
content = PlaceholderField('news_content')
How can i get a list of all connected News entries if I do have the project ID? (For backlinks on project detail page)