sdi/forms.py
author nishanth
Sat, 29 May 2010 15:46:00 +0530
changeset 20 9db4ee082d4e
parent 19 3932d9426c44
child 21 3d7a52d9ed2e
permissions -rw-r--r--
added topics choices and corresponding clean method

from django import forms

from sage_days.sdi.models import Registrant, TOPICS_CHOICES

class RegisterForm(forms.ModelForm):
    """ The form that is displayed to user.
    """

    topics_interested = forms.MultipleChoiceField(widget=forms.CheckboxSelectMultiple, choices=TOPICS_CHOICES, required=False)
    class Meta:
        model = Registrant

    def clean_topics_interested(self):
        """ Join the choices using PIPE character and store them.
        """

        topics = self.cleaned_data['topics_interested']
        return "|".join(topics)