diff --git a/docs/introduction/apphooks.rst b/docs/introduction/apphooks.rst
index 3189bc83bf6..72f71094840 100644
--- a/docs/introduction/apphooks.rst
+++ b/docs/introduction/apphooks.rst
@@ -3,7 +3,7 @@ Apphooks
#########
Right now, our django Polls app is statically hooked into the project's
-``urls.py``. This is allright, but we can do more, by attaching applications to
+``urls.py``. This is all right, but we can do more, by attaching applications to
django CMS pages.
We do this with an **Apphook**, created using a :class:`CMSApp
@@ -12,7 +12,9 @@ We do this with an **Apphook**, created using a :class:`CMSApp
Apphooks live in a file called ``cms_app.py``, so create one in your Poll
application.
-This is the most basic example for a django CMS app::
+This is the most basic example for a django CMS app:
+
+.. code-block:: python
from cms.app_base import CMSApp
from cms.apphook_pool import apphook_pool
diff --git a/docs/introduction/menu.rst b/docs/introduction/menu.rst
index 13cbbc6b8a4..92a9b06f340 100644
--- a/docs/introduction/menu.rst
+++ b/docs/introduction/menu.rst
@@ -9,16 +9,20 @@ is still only determined by django CMS Pages.
We can hook into the django CMS menu system to add our own nodes to that
navigation menu.
-For this we need a file called ``menu.py`` in the Polls application::
+For this we need a file called ``menu.py`` in our application. Add
+``polls_plugin/menu.py``:
+
+.. code-block:: python
from django.core.urlresolvers import reverse
from django.utils.translation import ugettext_lazy as _
from cms.menu_bases import CMSAttachMenu
- from menus.base import Menu, NavigationNode
+ from menus.base import NavigationNode
from menus.menu_pool import menu_pool
- from .models import Poll
+ from polls.models import Poll
+
class PollsMenu(CMSAttachMenu):
name = _("Polls Menu") # give the menu a name this is required.
@@ -29,24 +33,21 @@ For this we need a file called ``menu.py`` in the Polls application::
"""
nodes = []
for poll in Poll.objects.all():
- # the menu tree consists of NavigationNode instances
- # Each NavigationNode takes a label as its first argument, a URL as
- # its second argument and a (for this tree) unique id as its third
- # argument.
node = NavigationNode(
- poll.question,
- reverse('polls:detail', args=(poll.pk,)),
- poll.pk
+ title=poll.question,
+ url=reverse('polls:detail', args=(poll.pk,)),
+ id=poll.pk, # unique id for this node within the menu
)
nodes.append(node)
return nodes
- menu_pool.register_menu(PollsMenu) # register the menu.
+ menu_pool.register_menu(PollsMenu)
+
What's happening here:
* we define a ``PollsMenu`` class, and register it
-* we give the class a ``name`` attribute
+* we give the class a ``name`` attribute (will be displayed in admin)
* in its ``get_nodes()`` method, we build and return a list of nodes, where:
* first we get all the ``Poll`` objects
* ... and then create a ``NavigationNode`` object from each one
@@ -59,5 +60,5 @@ So open your ``cms_app.py`` and add::
to the ``PollsApp`` class.
-Now, any page that is attached to the ``Polls`` application have, below its
-own node in the navigation menu, a node for each of the Polls in the database.
+Any page that is attached to the ``Polls`` application will now have submenu
+items for each of the Polls in the database.
diff --git a/docs/introduction/plugins.rst b/docs/introduction/plugins.rst
index eff483abed6..446b3342944 100644
--- a/docs/introduction/plugins.rst
+++ b/docs/introduction/plugins.rst
@@ -29,18 +29,22 @@ You should end up with a folder structure similar to this::
Let's add it this application to our project. Add ``'polls'`` to the end of ``INSTALLED_APPS`` in
your project's `settings.py` (see the note on :ref:`installed_apps` about ordering ).
-Add the following line to ``urlpatterns`` in the project's ``urls.py``::
+Add the following line to ``urlpatterns`` in the project's ``urls.py``:
+
+.. code-block:: python
url(r'^polls/', include('polls.urls', namespace='polls')),
-Make sure this line is included **before** the line for the django-cms urls::
+Make sure this line is included **before** the line for the django-cms urls:
+
+.. code-block:: python
url(r'^', include('cms.urls')),
django CMS's URL pattern needs to be last, because it "swallows up" anything
that hasn't already been matched by a previous pattern.
-Now run the application's migrations using ``south``::
+Now run the application's migrations::
python manage.py migrate polls
@@ -51,8 +55,9 @@ However, in pages of the polls application we only have minimal templates, and
no navigation or styling. Let's improve this by overriding the polls
application's base template.
-add ``my_site/templates/polls/base.html``::
+add ``my_site/templates/polls/base.html``:
+.. code-block:: html+django
{% extends 'base.html' %}
@@ -104,7 +109,9 @@ So our workspace looks like this::
The Plugin Model
================
-In your poll application’s ``models.py`` add the following::
+In your poll application’s ``models.py`` add the following:
+
+.. code-block:: python
from django.db import models
from cms.models import CMSPlugin
@@ -129,7 +136,9 @@ Now create a file ``cms_plugins.py`` in the same folder your models.py is in.
The plugin class is responsible for providing django CMS with the necessary
information to render your plugin.
-For our poll plugin, we're going to write the following plugin class::
+For our poll plugin, we're going to write the following plugin class:
+
+.. code-block:: python
from cms.plugin_base import CMSPluginBase
from cms.plugin_pool import plugin_pool
@@ -170,23 +179,32 @@ the plugin which :attr:`render_template
In this case the template needs to be at
``polls_plugin/templates/djangocms_polls/poll_plugin.html`` and should look
-something like this::
+something like this:
+
+.. code-block:: html+django
{{ instance.poll.question }}
+
Now add ``polls_plugin`` to ``INSTALLED_APPS`` and create a database migration
-to add the plugin table (using South)::
+to add the plugin table::
- python manage.py schemamigration polls_plugin --init
+ python manage.py makemigrations polls
python manage.py migrate polls_plugin
Finally, start the runserver and visit http://localhost:8000/.
diff --git a/docs/introduction/templates_placeholders.rst b/docs/introduction/templates_placeholders.rst
index 5f328f2e722..4a88c6a3679 100644
--- a/docs/introduction/templates_placeholders.rst
+++ b/docs/introduction/templates_placeholders.rst
@@ -58,7 +58,9 @@ static placeholders from a template, you can reuse them later.
So let's add a footer to all our pages. Since we want our footer on every
single page, we should add it to our base template
-(``mysite/templates/base.html``). Place it at the bottom of the HTML body::
+(``mysite/templates/base.html``). Place it at the bottom of the HTML body:
+
+.. code-block:: html+django