Skip to content

Commit

Permalink
Merge pull request #3883 from mkoistinen/mkoistinen-feature/fix_plugi…
Browse files Browse the repository at this point in the history
…n_tutorial

Include `cache = False` in the 'simplest plugin' example.
  • Loading branch information
mkoistinen committed Feb 20, 2015
2 parents a5dae7d + 2f6a1e3 commit 64c179a
Showing 1 changed file with 8 additions and 1 deletion.
9 changes: 8 additions & 1 deletion docs/how_to/custom_plugins.rst
Original file line number Diff line number Diff line change
Expand Up @@ -110,6 +110,7 @@ In there, you place your plugins. For our example, include the following code::
class HelloPlugin(CMSPluginBase):
model = CMSPlugin
render_template = "hello_plugin.html"
cache = False

plugin_pool.register_plugin(HelloPlugin)

Expand Down Expand Up @@ -142,6 +143,11 @@ There are two required attributes on those classes:
good practice to mark this string as translatable using
:func:`django.utils.translation.ugettext_lazy`, however this is optional. By
default the name is a nicer version of the class name.
* ``cache``: This is a property that tells the plugin rendering system in django
CMS whether to cache the plugin’s output to speed-up subsequent views of the
same plugin. By default, the cms caches. Since we want each visitor to see
output that is specific to him or her, we need to tell the cms to not cache
this plugin.

And one of the following **must** be defined if ``render_plugin`` attribute
is ``True`` (the default):
Expand Down Expand Up @@ -217,6 +223,7 @@ Now we need to change our plugin definition to use this model, so our new
model = Hello
name = _("Hello Plugin")
render_template = "hello_plugin.html"
cache = False

def render(self, context, instance, placeholder):
context['instance'] = instance
Expand Down Expand Up @@ -305,7 +312,7 @@ have two models, one for the plugin and one for those items::
plugin = models.ForeignKey(
ArticlePluginModel,
related_name="associated_item"
)
)

You'll then need the ``copy_relations()`` method on your plugin model to loop
over the associated items and copy them, giving the copies foreign keys to the
Expand Down

0 comments on commit 64c179a

Please sign in to comment.