skip to navigation
skip to content

django-select-multiple-field 0.0.4

Select multiple choices in a single Django model field

Latest Version: 0.4.2

Select multiple choices in a single Django model field.


This Django module is not suitable for production use. It has not been sufficiently tested.

Quick Start


Field attribute max_length must be set to a value longer than your longest expected encoded string

In your models add the select field choices normally:


class Pizza(models.Model):
    ANCHOVIES = 'a'
    BLACK_OLIVES = 'b'
    PEPPERONI = 'p'
    MOZZARELLA = 'm'
        (ANCHOVIES, 'Anchovies'),
        (BLACK_OLIVES, 'Black olives'),
        (PEPPERONI, 'Pepperoni'),
        (MOZZARELLA, 'Mozzarella'),

    toppings = SelectMultipleField(

Use a generic view or a modelform as usual. In your template you can use a regular form tag:

# template_form.html

<form action="" method="post">
  {{ form  }}
  <input type="submit" value="Submit">

This renders the following HTML:

# create.html

<form action="" method="post">
      <label for="id_toppings">Toppings:</label>
      <select multiple="multiple" id="id_toppings" name="toppings" class="select-multiple-field">
        <option value="a">Anchovies</option>
        <option value="b">Black olives</option>
        <option value="p">Pepperoni</option>
        <option value="m">Mozzarella</option>
    <input type="submit" value="Submit">

Displaying stored choices

To display your choices, you will need to decode the field contents. This can be accomplished with a template tag:

# templatetags/

def decode_pie(ingredients):
    Decode pizza pie toppings
    decoder = dict(Pizza.TOPPING_CHOICES)
    decoded = [decoder[t] for t in ingredients]
    return ', '.join(decoded)

register.filter('decode_pie', decode_pie)

In your template you need to import your tags and use them:

# details.html

{% load pizza_tags %}

{{ pizza.toppings|decode_pie }}

Encoding the choices

The choices that are selected are stored as comma-delimited text. Consider a pizza with the following toppings.

  • Pepperoni
  • Mozzarella

This would be stored as a text field as:


The method may limit your ability to search for choices.

Sample application

There is a sample application included if you downloaded the tarball. You can try it like this:

$ pwd
$ cd test_projects/django14
$ python syncdb
$ python runserver

Validating models...

0 errors found
Django version 1.4.2, using settings 'django14.settings'
Development server is running at
Quit the server with CONTROL-C.


Django-select-multiple-field contains two test suites. One is for the field and one is for an implementation of the field in a Django 1.4.2 project.

You can run the field tests by downloading the tarball and running ‘test’ in

$ python test

You can run the Django 1.4.2 demo test in a similar manner:

$ python test_demo

Needless to say you will need to have Django 1.4.2 or later installed.

Bugs! Help!!

If you find any bugs in this software please report them via the Github issue tracker [1] or send an email to Any serious security bugs should be reported via email only.

[1]Django-select-multiple-field issue tracker


Thank-you for taking the time to evaluate this software. I appreciate receiving feedback on your experiences using it and I welcome code contributions and development ideas.

File Type Py Version Uploaded on Size
django-select-multiple-field-0.0.4.tar.gz (md5, pgp) Source 2014-05-25 26KB