Plone and Django: Comparing Tools for Python Web Developers

Justin James and Brian Gershon

Web Collective, Inc
http://www.webcollective.coop

plone and django logos

Seattle Plone, April 2008

Presentation Abstract

Justin James and Brian Gershon of Web Collective will be talking about their recent experiences with Django, an exciting python-based web framework, and will show examples from both Django and Plone to give a sense of the strengths of each platform and when one might use one or the other. There are also some shared concepts between these two platforms. The presentation will be a high-level discussion, plus will also delve into some code -- so should be good for a technical and non-technical audience.

This is also an invitation to those that know Django really well to participate in the conversation, and also Django users that want to learn more about Plone.

Presentation Overview

Framework Goals

Goal of these frameworks are to:

Why Plone (and Zope3)?

Why Django?

Data Layer: How are data and content handled? (Plone)

Plone:

Archetypes Schema

Data Layer: How are data and content handled? (Plone)

Plone:

Archetypes Subclass

Data Layer: Accessing data (Plone)

Plone:

Plone Db Interaction

Data Layer: Accessing data (Plone)

Plone:

Plone Data Access

Data Layer: How are data and content handled? (Django)

Django:

Django Models

Data Layer: Accessing data (Django)

Django:

Django Shell

Data Layer: Accessing data (Django)

Django:

Django Db Interaction

Data Layer: Hierarchy and Relationships

Contained VS. Related:

Gs

Data Layer: Hierarchy and Relationships

Contained VS. Related:

Plone Relationships

Data Layer: Hierarchy and Relationships

Contained VS. Related:

Dj Relationships

Views: Pulling together data, functionality and presentation

"Views" on both platforms are essentially Python classes that receive information from the browser, and return information back.

browser -> URL Mapping -> Python classes -> template -> browser

They differ in their approaches however.

What is a View in Plone?

...well, it's really a Zope3 View

Example Plone View: Show a list of ActionItems

(snippets from CollectiveGTD Plone product)

Screenshot of CollectiveGTD's ActionItemList View

Calling a View in Plone

Note: In Plone, you can setup views in two slightly different ways: You can call a template (and it can pull in the View functionality) or you can call a View directly and it will pull in the template. An example of the first way comes up shortly.

Plone View: Interface

Plone View: A Python class

Plone View: Template

Plone View: Configuration File

What is a View in Django?

Example Django View: Show a person's profile

(snippets from Skillbit.com product)

Screenshot of a Django View in Skillbit.com

Django View: A Python function

Django View: Template

Django View: URL Mapping

Calling a View in Django

In Django, a common pattern is to map a url to a View, and pass parameters between slashes. It's easier to read than query string parameters.

    http://127.0.0.1:8000/profile/2/

Flip back to previous slide to walk through how this works.

Templating: The Presentation Layer (Plone)

Plone Template

Templating: The Presentation Layer (Plone)

Templating: The Presentation Layer (Django)

Templating: The Presentation Layer (Django)

Dj Base Template

Templating: The Presentation Layer (Django)

template extension:

Dj Extends

Templating: The Presentation Layer (Django)

Dj Template Relations

Wrapping Up