=========================================== Welcome to django-portlets's documentation! =========================================== What is it? =========== Portlets are pieces of content which are managed in Slots. Slots can be freely defined and placed anywhere within a HTML page. django-portlets provides just a generic engine to manage portlets. You can find a comprehensive implementation within `LFS`_. Installation ============ To install just do: 1. ``python setup.py install`` or ``easy_install django-portlets`` 2. Add portlets to *INSTALLED_APPS*. Usage ===== In order to use django-portlets you first have to implement a portlet. This is done by inheriting from the provided base class, for instance: **Create a portlet** Let's create a simple text portlet:: # django imports from django import forms from django.db import models from django.template.loader import render_to_string from django.utils.translation import ugettext_lazy as _ from portlets.models import Portlet class TextPortlet(Portlet): """A simple portlet to display some text. """ text = models.TextField(_(u"Text"), blank=True) def __unicode__(self): return "%s" % self.id def render(self, context): """Renders the portlet as html. """ return render_to_string("portlets/text_portlet.html", { "title" : self.title, "text" : self.text }) def form(self, **kwargs): """ """ return TextPortletForm(instance=self, **kwargs) class TextPortletForm(forms.ModelForm): """Form for the TextPortlet. """ class Meta: model = TextPortlet **Create the template** To display the content of the portlet we will have to create a simple template in this case text_portlet.html. It can look like this::
{% portlet_slot 'Left' flatpage %} | Content goes here. | {% portlet_slot 'Right' flatpage %} |