title: Django how to pass value from template to view
body: <p>i want this functionality. User enters email address, and somehow it has to be passed to my views.py file, so i could then email the user that he has succesfully registered.</p>
  
  <p>This is my template file:</p>
  
  <pre><code>{% extends "base.html" %}
  
  {% block content %}
  
  &lt;section&gt;
  &lt;h2 style="text-align: center"&gt;Register&lt;/h2&gt;
  &lt;form action="/accounts/register/" method="post"&gt;{% csrf_token %}
  
  &lt;ul&gt;
  {{form.as_ul}}
  &lt;/ul&gt;
  &lt;input type="submit" value="Register" onclick="validateForm()"/&gt;
  
  &lt;/form&gt;
  
  &lt;/section&gt;
  {% endblock %}
  </code></pre>
  
  <p>this is my forms.py file:</p>
  
  <pre><code>class MyRegistrationForm(UserCreationForm):
      #kokie fields bus displayed html form
      email = forms.EmailField(required=True)
      firstname = forms.CharField(required=True)
      lastname = forms.CharField(required=True)
      whoinvitedyou = forms.CharField(required=True)
      phone = forms.CharField(required=True)
      workplace = forms.CharField(required=True)
  
      class Meta:
          model = User
          fields = ('username', 'email', 'password1', 'password2', 'firstname', 'lastname', 'whoinvitedyou', 'phone', 'workplace')
  
      def save(self, commit=True):
          user = super(MyRegistrationForm, self).save(commit=False)
          user.email = self.cleaned_data['email']
          user.set_password(self.cleaned_data["password1"])
  #more fields for name last name
          user.firstname = self.cleaned_data['firstname']
          user.lastname = self.cleaned_data['lastname']
          user.whoinvitedyou = self.cleaned_data['whoinvitedyou']
          user.phone = self.cleaned_data['phone']
          user.workplace = self.cleaned_data['workplace']
  
          if commit:
              user.save()
  
          return user
  </code></pre>
  
  <p>this is my views.py:</p>
  
  <pre><code>def register_user(request):
      if request.method == 'POST':
          form = MyRegistrationForm(request.POST)
          if form.is_valid():
              form.save()
              return HttpResponseRedirect('/accounts/register_success')
          else:
              return render_to_response('invalid_reg.html')
  
      args = {}
      args.update(csrf(request))
  
      args['form'] = MyRegistrationForm()
      print args
      return render_to_response('register.html', args)
  </code></pre>
  
  <p>how do i pass the value so later i can use it? maybe somebody can help me with this...</p>