为什么我无法获取我插件的相关objects?
Why I can't get the related objects of my pulgin?
我有一些模型
# 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)
并注册插件
# 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)
当我被自动化时,我在模板
中看到了所有相关的objects
{# contact/contact_block.html #}
{% for email in instance.emails.all %}
<a href="mailto:{{ email.email }}">{{ email.email }}</a>
{% endfor %}
但如果我来宾,collections instance.emails.all()
是空的。
这是一个错误?或者没有?
我怀疑 objects 的 django 权限问题,但是如何为访客用户设置它?
Django==1.7.10
django-cms==3.1.2
提前致谢
如果你的插件有数据库关系,你需要指示django CMS在复制时做什么,见http://docs.django-cms.org/en/develop/how_to/custom_plugins.html#handling-relations
我有一些模型
# 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)
并注册插件
# 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)
当我被自动化时,我在模板
中看到了所有相关的objects{# contact/contact_block.html #}
{% for email in instance.emails.all %}
<a href="mailto:{{ email.email }}">{{ email.email }}</a>
{% endfor %}
但如果我来宾,collections instance.emails.all()
是空的。
这是一个错误?或者没有?
我怀疑 objects 的 django 权限问题,但是如何为访客用户设置它?
Django==1.7.10 django-cms==3.1.2
提前致谢
如果你的插件有数据库关系,你需要指示django CMS在复制时做什么,见http://docs.django-cms.org/en/develop/how_to/custom_plugins.html#handling-relations