snakesNbronies
snakesNbronies

Reputation: 3920

Django-CMS - CMS section of admin disappears when I specify a model

I'm trying to duplicate the example in 2.4 in the Django-CMS docs (http://docs.django-cms.org/en/2.3.5/extending_cms/custom_plugins.html). However, whenever I specify the model in cms_plugins.py under class HelloPlugin, the entire CMS section in the admin disappears. Any idea what's causing this?

models.py

from django.db import models

class MyModel(models.Model):
    title = models.CharField(max_length=50, null=True, blank=True)

    def __unicode__(self):
        return self.title

from cms.models.pluginmodel import CMSPlugin

class HelloPlugin(CMSPlugin):
    ad = models.ForeignKey('core.MyModel', related_name='plugins')

    def __unicode__(self):
      return self.ad.title

cms_plugins.py

class HelloPlugin(CMSPluginBase):
    model = MyModel
    name = _("MyModel Plugin")
    render_template = "myplugin.html"

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

plugin_pool.register_plugin(HelloPlugin)

Upvotes: 0

Views: 108

Answers (1)

snakesNbronies
snakesNbronies

Reputation: 3920

Small, but significant mistake. I was importing the model, and not the plugin.

Upvotes: 0

Related Questions