Django self.cleaned_data problems.
<p>Have a fully working form created in Django - however it breaks when I try to define a function to raise custom <code>form.ValidationError</code>. </p>

<pre><code> # importing form modules

from django import forms
import re

# define the forms

class single_input(forms.Form):

    CHROMOSOMES = (

                    ('1'  ,  '1'),
                    ('2'  ,  '2'),
                    ('3'  ,  '3'),
                    ('4'  ,  '4'),
                    ('5'  ,  '5'),
                    ('6'  ,  '6'),
                    ('7'  ,  '7'),
                    ('8'  ,  '8'),
                    ('9'  ,  '9'),
                    ('10' ,  '10'),
                    ('11' ,  '11'),
                    ('12' ,  '12'),
                    ('13' ,  '13'),
                    ('14' ,  '14'),
                    ('15' ,  '15'),
                    ('16' ,  '16'),
                    ('17' ,  '17'),
                    ('18' ,  '18'),
                    ('19' ,  '19'),
                    ('20' ,  '20'),
                    ('21' ,  '21'),
                    ('22' ,  '22'),
                    ('23' ,  '23'),
                    ('X'  ,  'X'),
                    ('Y ' ,  'Y')

                    ) 

    def clean_testname(self):

        print self.cleaned_data

        testname      = self.cleaned_data['testname']   
        genome_pos    = self.cleaned_data['genome_pos']


        if ( not re.match(r"^\w+$", testname)):

            raise forms.ValidationError(

                "Test name is only allowed letter's number's and _'s ."
                "NO spaces or funny things that involve the shift button"  
                )

        if ( not re.match(r"^\s+$", genome_pos)):

            raise forms.ValidationError(

                "Genome position is only allowed numbers and -'s"
                "NO spaces, letter or funny things that involve the shift button"

                ) 


        return cleaned_data


    testname   = forms.CharField ( label='testname', max_length=100 )
    chromosome = forms.ChoiceField( label='chromosome', choices = CHROMOSOMES , required = True)
    genome_pos = forms.CharField ( label='genome_pos', max_length=15 )
</code></pre>

<p>The problem is it only takes the first form field into <code>cleaned_data</code> so a <code>print cleaned_data</code> from the above code looks like:</p>

<pre><code>{'testname': u'ssss'}
</code></pre>

<p>Wheras if I comment out the entire <code>clean_testname</code> function I get a working output  </p>

<pre><code>{'genome_pos': u'xxx', 'testname': "name", 'chromosome': u'1'}
</code></pre>