Richtemplates provides some widgets helping to use it’s styles and other goodies.
Copied from django.forms.CheckboxSelectMultiple with additional img icons tags. With javascript enabled allows to check single box by clicking on it’s row / label / box. Uses nice css highlighting.
Full example:
from django import forms
from richtemplates.widgets import RichCheckboxSelectMultiple
def unslugify(value):
return value.replace('_', ' ').replace('-', ' ').capitalize()
class MultipleChoicesForm(forms.Form):
CHOICES = ((key, unslugify(key)) for key in (
('view_project'),
('edit_project'),
('add_project'),
('delete_project'),
))
fake_permissions = forms.MultipleChoiceField(choices=CHOICES,
initial = ['view_project'],
required = False,
widget = RichCheckboxSelectMultiple)
Widget adding some extras from markItUp. Not using django-markitup as we needed only restructuredtext markup and by requiring to set that specific filter wouldn’t allow one to use django-markitup with other renderer type. Ajax preview is nicer but it consumes more resources as it is called each time user hits keyboard - so use it on own risk.
Returns default url for rst preview processing view.