0

I have some model

# models.py

class Email(models.Model):
    email =         models.EmailField(blank=False, null=False)
    contact_block = models.ForeignKey('contact.ContactBlockPlugin', related_name='emails', blank=False, null=False)

class ContactBlockPlugin(CMSPlugin):
    address =       models.TextField(blank=False, null=False)

And register pulgins

# cms_plugins.py

class EmailInlineAdmin(admin.TabularInline):
    model = Email

class CMSContactBlockPlugin(CMSPluginBase):
    model =     ContactBlockPlugin
    render_template =   'contact/contact_block.html'
    inlines =   (EmailInlineAdmin, )


plugin_pool.register_plugin(CMSContactBlockPlugin)

When I'm autorized, I see all related objects in template

{# contact/contact_block.html #}

{% for email in instance.emails.all %}
    <a href="mailto:{{ email.email }}">{{ email.email }}</a>
{% endfor %}

But if I guest, the collections instance.emails.all() is empty.

It's a bug? Or no?

I suspect that the issue of the django permissions for objects, but how set it for guest users?

Django==1.7.10 django-cms==3.1.2

Thank you in advance

Dmitry
  • 551
  • 6
  • 19

1 Answers1

1

If your plugin has database relation, you need to instruct django CMS what to do on copy, see http://docs.django-cms.org/en/develop/how_to/custom_plugins.html#handling-relations

ojii
  • 4,729
  • 2
  • 23
  • 34