title: Setting value of a hidden field in Django form
body: <p>I'm using <code>django-registration</code> to manage my registrations.  I'm trying to force my username and email to be the same in a Django application and I am trying to do it via the registration form as follows:</p>
  
  <pre><code>class NoUsernameRegistrationForm(RegistrationForm):
      """
      Form for registering a new user account.
  
      Requires the password to be entered twice to catch typos.
  
      Subclasses should feel free to add any additional validation they
      need, but should avoid defining a ``save()`` method -- the actual
      saving of collected user data is delegated to the active
      registration backend.
  
      """
      username = forms.CharField(
          widget=forms.EmailInput(attrs=dict(attrs_dict, maxlength=75)),
          label=_("Email address"))
      password1 = forms.CharField(
          widget=forms.PasswordInput(attrs=attrs_dict, render_value=False),
          label=_("Password"))
      password2 = forms.CharField(
          widget=forms.PasswordInput(attrs=attrs_dict, render_value=False),
          label=_("Password (again)"))
      email = forms.EmailField(
          widget=forms.HiddenInput(),
          required = False)
  
  
      def clean(self):
          """
          Verify that the values entered into the two password fields
          match. Note that an error here will end up in
          ``non_field_errors()`` because it doesn't apply to a single
          field.
  
          """
          if 'password1' in self.cleaned_data and 'password2' in self.cleaned_data:
              if self.cleaned_data['password1'] != self.cleaned_data['password2']:
                  raise forms.ValidationError(_("The two password fields didn't match."))
  
          """
          Validate that the email address is not already in use.
  
          """
          try:
              user = User.objects.get(username__iexact=self.cleaned_data['username'])
              raise forms.ValidationError(_("A user with that email address already exists."))
          except User.DoesNotExist:
              self.cleaned_data['email'] = self.cleaned_data['username']
              self.cleaned_data['username']
  
  
          return self.cleaned_data
  </code></pre>
  
  <p>The idea is that if passwords match and the <code>username</code> is valid then I set the <code>email</code> to the <code>username</code>.  But I just get the error <code>(Hidden field email) This field is required</code></p>
  
  <p>How should I set this.</p>