<commit_before>###########################
Extending the CMS: Examples
###########################

From this part onwards, this tutorial assumes you have done the
`Django Tutorial`_ and we will show you how to integrate that poll app into the
django CMS. If a poll app is mentioned here, we mean the one you get when
finishing the `Django Tutorial`_.

We assume your main ``urls.py`` looks somewhat like this::

    from django.conf.urls.defaults import *

    from django.contrib import admin
    admin.autodiscover()

    urlpatterns = patterns('',
        (r'^admin/', include(admin.site.urls)),
        (r'^polls/', include('polls.urls')),
        (r'^', include('cms.urls')),
    )

***************
My First Plugin
***************

A Plugin is a small bit of content you can place on your pages.

The Model
=========

For our polling app we would like to have a small poll plugin, that shows one
poll and let's the user vote.

In your poll application's ``models.py`` add the following model::

    from cms.models import CMSPlugin
    
    class PollPlugin(CMSPlugin):
        poll = models.ForeignKey('polls.Poll', related_name='plugins')
        
        def __unicode__(self):
          return self.poll.question


.. note:: django CMS Plugins must inherit from ``cms.models.CMSPlugin`` (or a
          subclass thereof) and not ``django.db.models.Model``.

Run ``syncdb`` to create the database tables for this model or see
:doc:`using_south` to see how to do it using `South`_


The Plugin Class
================<commit_msg>fixed wrong link in sphinx docs<commit_after>###########################
Extending the CMS: Examples
###########################

From this part onwards, this tutorial assumes you have done the
`Django Tutorial`_ and we will show you how to integrate that poll app into the
django CMS. If a poll app is mentioned here, we mean the one you get when
finishing the `Django Tutorial`_.

We assume your main ``urls.py`` looks somewhat like this::

    from django.conf.urls.defaults import *

    from django.contrib import admin
    admin.autodiscover()

    urlpatterns = patterns('',
        (r'^admin/', include(admin.site.urls)),
        (r'^polls/', include('polls.urls')),
        (r'^', include('cms.urls')),
    )

***************
My First Plugin
***************

A Plugin is a small bit of content you can place on your pages.

The Model
=========

For our polling app we would like to have a small poll plugin, that shows one
poll and let's the user vote.

In your poll application's ``models.py`` add the following model::

    from cms.models import CMSPlugin
    
    class PollPlugin(CMSPlugin):
        poll = models.ForeignKey('polls.Poll', related_name='plugins')
        
        def __unicode__(self):
          return self.poll.question


.. note:: django CMS Plugins must inherit from ``cms.models.CMSPlugin`` (or a
          subclass thereof) and not ``django.db.models.Model``.

Run ``syncdb`` to create the database tables for this model or see
:doc:`../getting_started/using_south` to see how to do it using `South`_


The Plugin Class
================
{'fraction_non_alphanumeric': 0.1563203602444516, 'fraction_numerical': 0.0, 'mean_word_length': 3.573529411764706, 'pattern_counts': {'":': 0, '<': 3, '<?xml version=': 0, '>': 3, 'https://': 0, 'lorem ipsum': 0, 'www.': 0, 'xml': 0}, 'pii_count': 0, 'substrings_counts': 0, 'word_list_counts': {'cursed_substrings.json': 0, 'profanity_word_list.json': 0, 'sexual_word_list.json': 0, 'zh_pornsignals.json': 0}}
{'dir': 'git-commits-cleaned', 'id': '2966415', 'n_tokens_mistral': 896, 'n_tokens_neox': 851, 'n_words': 361}