KodoBlog | tech practice & philosophy

  • Contact me
  • Thanks to
  • Archive
  • RSS
Jun 04
2:27 pm →

Django Widget for CommaSeparatedIntegerField with pre-defined choices

Assume, we need a registration form for some event with time frame for 3 days, starting at Monday. User can select any of 3 days, so we need to show 3 checkboxes.

Here’s the basic example for such form:

class EventRegistrationForm(forms.Form):
    days = forms.CharField(widget=NumbersSelectionWidget(
                    ['Mon', 'Tue', 'Wed'], range(1, 4)))

http://djangosnippets.org/snippets/2051/
Tags: django python snippet django-widget  

← Older Newer →