Clone wiki

DJPoller / Home

DJ Poller

This is a Django-Poller, a widget to quickly set up simple polls. Given there is a gazillion of such thingies in PHP, we need at least one for Python...

Demo site

See here: It shows various polls in different configurations; allows you to log in as admin and play with them (database is reset every hour).

How does it work

Provides two template tags to insert polls into templates:

{% load poller_tags %}
{% poller_poll slug %}
{% poller_current_poll %}

The first inserts a poll with the given slug; the second form inserts a poll which is marked as "current" (see below) or does nothing if there is no current poll.

Polls are loaded asynchonously after the page has loaded; answering is AJAX - it doesn't reload the page.

Polls have many configuration options - see below.


Like any other Django app - clone, add to

Your page must link a more or less version of jQuery, the poller's JS and the default CSS for polls:

<script type="text/javascript" src="/site_media/jquery.js"></script>
<script type="text/javascript" src="/site_media/poller.js"></script>
<link type="text/css" rel="stylesheet" href="/site_media/poller.css"/>

Poll configuration

  • Question - it is a question, unquestionably
  • Slug - a poll identifier
  • Current - you can mark one poll as the "current" one; it will then be picked by the template tag "poller_current_poll"
  • Members only - makes the poll visible to authenticated users only
  • Invite to log in - valid for members-only polls, displays a question and a message telling the user to log in (otherwise anonymous user will not see anything)
  • Closed - when checked, the poll widget shows only results and doesn't allow to vote
  • Answer limit - controls how many times and in what circs a user can answer
  • Once - for members-only executes full control, otherwise sets a permament browser cookie
  • Once per session - cookie-based control which expires at browser close
  • Unlimited - you can answer, reload a page and answer again
  • Choices - just a list of answers, as simple as that.
  • Extra classes - apply some CSS classes defined in global CSS files to this poll
  • Use local styles - if checked, the poll will use the styles defined below
  • Local styles - here you can manually tweak the poll layout; by default the field contains some empty classes to get you started


The Poll's admin form has "view on page" link which shows results.

The Answer model can be reviewed and (in some extreme cases) modified. For example, if you edit a choice while the poll is running, you should edit or delete answers which used the old form; otherwise results will show both old and new form of the choice. This is because the design of the model is very simple - answers are recorded and aggregates as they are. It makes the whole thing very simple and very fast, thought it has the above drawback.