title: Display django form error for each field in template and each correct data in template
body: <p>I am new to django and i am trying to validate form data and if any error occurs transfer that data to the template page with the old values to display in the form. If possible i want the error message for each data in dictionary  </p>
  
  <p>views.py</p>
  
  <pre><code>from django.shortcuts import render
  
  from .forms import RegForm
  
  # Create your views here.
  def login(request):
  
      return render(request, 'login.html')
  
  def registration(request):
      if request.method == 'POST':
          form = RegForm(request.POST)
  
          if form.is_valid():
              print "Form is valid"
              print form.cleaned_data
  
              user_data = {
                  'firstname':form.cleaned_data['firstname'],
                  'lastname':form.cleaned_data['secondname'],
                  'username': form.cleaned_data['username'],
                  'mail':form.cleaned_data['mail'],
                  'password': form.cleaned_data['password']}
              print user_data
          else:
              print "Form is not valid"
              print form['mail'].errors
      return render(request, 'register.html')
     forms.py
  
  
  
      from django import forms
  
      class RegForm(forms.Form):
  
          firstname = forms.CharField(max_length=100)
          secondname = forms.CharField(max_length=100)
          username = forms.CharField(max_length=100, min_length=8)
          mail = forms.EmailField()
          password = forms.CharField(widget = forms.PasswordInput(), min_length=8, max_length=100)
  </code></pre>
  
  <p>register.html</p>
  
  <pre><code>     &lt;!DOCTYPE html&gt;
      &lt;html&gt;
          &lt;head&gt;
              &lt;title&gt;registration&lt;/title&gt;
              &lt;style type="text/css"&gt;
                  header{
                      width: 100%;
                      display: block;
                  }
                  section{
                      width: 180px;
                      margin: auto;
                      display: block;
                  }
                  nav{
                      width: 180px;
                      float: right;
                      display: block;
                  }
  
              &lt;/style&gt;
      &lt;/head&gt;
      &lt;body&gt;
          &lt;header&gt;
              &lt;nav&gt;
                  &lt;a href="{% url 'registration' %}"&gt;Registration&lt;/a&gt;
                  &lt;a href="{% url 'login' %}"&gt;Login&lt;/a&gt;
              &lt;/nav&gt;
          &lt;/header&gt;
          &lt;section&gt;
          &lt;h1 align="center"&gt;Register:&lt;/h1&gt;
              &lt;form method = "post" action = "{% url 'registration' %}"&gt;
                  {% csrf_token %}
                  &lt;label&gt;First Name:&lt;/label&gt;&lt;br&gt;
                  &lt;input type="text" name="firstname"&gt;&lt;br&gt;
                  &lt;label&gt;Second Name:&lt;/label&gt;&lt;br&gt;
                  &lt;input type="text" name="secondname"&gt;&lt;br&gt;
                  &lt;label&gt;Mail Id:&lt;/label&gt;&lt;br&gt;
                  &lt;input type="text" name="mail"&gt;&lt;br&gt;
                  &lt;label&gt;User Name:&lt;/label&gt;&lt;br&gt;
                  &lt;input type="text" name="username" value=""&gt;&lt;br&gt;
                  &lt;label&gt;Password:&lt;/label&gt;&lt;br&gt;
                  &lt;input type="password" name="password"&gt;&lt;br&gt;&lt;br&gt;
                  &lt;input type="submit" name="submit" value="submit"&gt;
              &lt;/form&gt;
          &lt;/section&gt;
  
      &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>