How to custom render a Django checkbox list

You create a form widget that extends the CheckboxSelectMultiple

class CheckboxSelectMultiple(widgets.CheckboxSelectMultiple):
    """
    Simply adds a class to the ul element,
    which allows the CSS to select it.
    """

    def render(self, *args, **kwargs):
        output = super(CheckboxSelectMultiple,
                    self).render(*args,**kwargs)
        return mark_safe(output.replace(u'<ul>',
                         u'<ul class="checkbox- select">')) 
0 Comments, 0 trackbacks (Trackback URL)

0 responses to How to custom render a Django checkbox list

Leave a Comment
  1. (required)
  2. Ignore this field:
  3. Don't put anything in this field:
    Don't put anything here:
  4. Leave this empty:
    (required)
  5. Your email is not publically displayed.