title: Caught KeyError while rendering: 'phone_mobile'
body: <p>forms.py</p>
  
  <pre><code>class UserCreateProfileForm(forms.ModelForm):
      phone_daytime = forms.IntegerField(required=False)
      phone_mobile = forms.IntegerField(required=False)
      class Meta:
          model = UserProfile
          fields = ['phone_daytime', 'phone_mobile']
  def clean(self):
      cleaned_data = self.cleaned_data
      phone_daytime = cleaned_data.get('phone_daytime')
      phone_mobile = cleaned_data.get('phone_mobile')
  
      if not any([phone_daytime, phone_mobile]):
          self._errors['phone_daytime'] = self.error_class(['Enter a valid phone number'])
          del self.cleaned_data['phone_daytime']
          self._errors['phone_mobile'] = self.error_class(['Enter a valid phone number'])
          del self.cleaned_data['phone_mobile']
      return cleaned_data
  </code></pre>
  
  <p>template.py</p>
  
  <pre><code> &lt;tr&gt;
       &lt;td&gt;Daytime phone:&lt;/td&gt;&lt;td&gt;{{ form.phone_daytime }}{{ form.phone_daytime.errors }}&lt;/td&gt;
    &lt;/tr&gt;
    &lt;tr&gt;
       &lt;td&gt;Mobile phone:&lt;/td&gt;&lt;td&gt;{{ form.phone_mobile }}{{ form.phone_mobile.errors }}&lt;/td&gt;
    &lt;/tr&gt;
  </code></pre>
  
  <p>I am getting this error "<code>Caught KeyError while rendering: 'phone_mobile'</code>" when i enter some character in "phone_daytime" field.Appart from all other validations are working.</p>
  
  <p>Please see my complete traceback</p>
  
  <pre><code>Environment:
  
  
  Request Method: POST
  Request URL: http://192.168.100.10/member/about-me/
  
  Django Version: 1.3.7
  Python Version: 2.7.0
  Installed Applications:
  ['django.contrib.auth',
   'django.contrib.contenttypes',
   'django.contrib.sessions',
   'django.contrib.sites',
   'django.contrib.messages',
   'django.contrib.staticfiles',
   'django.contrib.admin',
   'django.contrib.admindocs',
   'django.contrib.humanize',
   'django.contrib.staticfiles',
   'south',
   'collect',
   'incident']
  Installed Middleware:
  ('django.middleware.common.CommonMiddleware',
   'django.contrib.sessions.middleware.SessionMiddleware',
   'django.middleware.csrf.CsrfViewMiddleware',
   'django.contrib.auth.middleware.AuthenticationMiddleware',
   'django.contrib.messages.middleware.MessageMiddleware',
   'django.middleware.transaction.TransactionMiddleware',
   'django.middleware.cache.FetchFromCacheMiddleware')
  
  
  Template error:
  In template /root/Projects/ir/templates/incident/about_me.html, error at line 332
     Caught KeyError while rendering: 'phone_mobile'
     322 :                             &lt;table  width="100%"&gt;
  
  
     323 :                                 &lt;tr&gt;
  
  
     324 :                                     &lt;td&gt;&lt;/td&gt;&lt;td&gt;*  Mandatory Fields&lt;/td&gt;&lt;/tr&gt;
  
  
     325 :                                 &lt;tr&gt;
  
  
     326 :                                     &lt;td style="width:100px;"&gt;First name:&lt;/td&gt;&lt;td&gt;{{registerform.first_name|capfirst}}*{{registerform.first_name.errors}}&lt;/td&gt;
  
  
     327 :                                 &lt;/tr&gt;
  
  
     328 :                                 &lt;tr&gt;
  
  
     329 :                                     &lt;td&gt;Last name:&lt;/td&gt;&lt;td&gt;{{registerform.last_name}}*{{registerform.last_name.errors}}&lt;/td&gt;
  
  
     330 :                                 &lt;/tr&gt;
  
  
     331 :                                 &lt;tr&gt;
  
  
     332 :                                     &lt;td&gt;Daytime phone:&lt;/td&gt;&lt;td&gt;{{createprofile.phone_daytime|default:""}} {{createprofile.phone_daytime.errors }} &lt;/td&gt;
  
  
     333 :                                 &lt;/tr&gt;
  
  
     334 :                                 &lt;tr&gt;
  
  
     335 :                                     &lt;td&gt;Mobile phone:&lt;/td&gt;&lt;td&gt;{{createprofile.phone_mobile|safe}}{{createprofile.phone_mobile.errors }}&lt;/td&gt;
  
  
     336 :                                 &lt;/tr&gt;
  
  
     337 :                                 &lt;tr&gt;
  
  
     338 :                                     &lt;td&gt;Email:&lt;/td&gt;&lt;td&gt;{{registerform.email}}*{{registerform.email.errors }}&lt;/td&gt;
  
  
     339 :                                 &lt;/tr&gt;
  
  
     340 :                                 &lt;tr&gt;
  
  
     341 :                                     &lt;td&gt;User name&lt;/td&gt;&lt;td&gt;{{registerform.username}}*{{registerform.username.errors }}&lt;/td&gt;
  
  
     342 :                                 &lt;/tr&gt;
  
  
  Traceback:
  File "/usr/lib/python2.7/site-packages/django/core/handlers/base.py" in get_response
    111.                         response = callback(request, *callback_args, **callback_kwargs)
  File "/usr/lib/python2.7/site-packages/django/contrib/auth/decorators.py" in _wrapped_view
    23.                 return view_func(request, *args, **kwargs)
  File "/root/Projects/ir/incident/decorators.py" in wrapper
    17.             return func(request, *args, **kwargs)
  File "/root/Projects/ir/incident/views.py" in about_me
    408.                    'is_member_screen':is_member_screen
  File "/usr/lib/python2.7/site-packages/django/shortcuts/__init__.py" in render
    44.     return HttpResponse(loader.render_to_string(*args, **kwargs),
  File "/usr/lib/python2.7/site-packages/django/template/loader.py" in render_to_string
    188.         return t.render(context_instance)
  File "/usr/lib/python2.7/site-packages/django/template/base.py" in render
    123.             return self._render(context)
  File "/usr/lib/python2.7/site-packages/django/template/base.py" in _render
    117.         return self.nodelist.render(context)
  File "/usr/lib/python2.7/site-packages/django/template/base.py" in render
    744.                 bits.append(self.render_node(node, context))
  File "/usr/lib/python2.7/site-packages/django/template/debug.py" in render_node
    73.             result = node.render(context)
  File "/usr/lib/python2.7/site-packages/django/template/loader_tags.py" in render
    127.         return compiled_parent._render(context)
  File "/usr/lib/python2.7/site-packages/django/template/base.py" in _render
    117.         return self.nodelist.render(context)
  File "/usr/lib/python2.7/site-packages/django/template/base.py" in render
    744.                 bits.append(self.render_node(node, context))
  File "/usr/lib/python2.7/site-packages/django/template/debug.py" in render_node
    73.             result = node.render(context)
  File "/usr/lib/python2.7/site-packages/django/template/loader_tags.py" in render
    127.         return compiled_parent._render(context)
  File "/usr/lib/python2.7/site-packages/django/template/base.py" in _render
    117.         return self.nodelist.render(context)
  File "/usr/lib/python2.7/site-packages/django/template/base.py" in render
    744.                 bits.append(self.render_node(node, context))
  File "/usr/lib/python2.7/site-packages/django/template/debug.py" in render_node
    73.             result = node.render(context)
  File "/usr/lib/python2.7/site-packages/django/template/loader_tags.py" in render
    127.         return compiled_parent._render(context)
  File "/usr/lib/python2.7/site-packages/django/template/base.py" in _render
    117.         return self.nodelist.render(context)
  File "/usr/lib/python2.7/site-packages/django/template/base.py" in render
    744.                 bits.append(self.render_node(node, context))
  File "/usr/lib/python2.7/site-packages/django/template/debug.py" in render_node
    73.             result = node.render(context)
  File "/usr/lib/python2.7/site-packages/django/template/loader_tags.py" in render
    64.             result = block.nodelist.render(context)
  File "/usr/lib/python2.7/site-packages/django/template/base.py" in render
    744.                 bits.append(self.render_node(node, context))
  File "/usr/lib/python2.7/site-packages/django/template/debug.py" in render_node
    73.             result = node.render(context)
  File "/usr/lib/python2.7/site-packages/django/template/debug.py" in render
    90.             output = self.filter_expression.resolve(context)
  File "/usr/lib/python2.7/site-packages/django/template/base.py" in resolve
    510.                 obj = self.var.resolve(context)
  File "/usr/lib/python2.7/site-packages/django/template/base.py" in resolve
    653.             value = self._resolve_lookup(context)
  File "/usr/lib/python2.7/site-packages/django/template/base.py" in _resolve_lookup
    683.                         current = getattr(current, bit)
  File "/usr/lib/python2.7/site-packages/django/forms/forms.py" in _errors
    415.         return self.form.errors.get(self.name, self.form.error_class())
  File "/usr/lib/python2.7/site-packages/django/forms/forms.py" in _get_errors
    112.             self.full_clean()
  File "/usr/lib/python2.7/site-packages/django/forms/forms.py" in full_clean
    268.         self._clean_form()
  File "/usr/lib/python2.7/site-packages/django/forms/forms.py" in _clean_form
    296.             self.cleaned_data = self.clean()
  File "/root/Projects/ir/incident/forms.py" in clean
    183.             del self.cleaned_data['phone_mobile']
  
  Exception Type: TemplateSyntaxError at /member/about-me/
  Exception Value: Caught KeyError while rendering: 'phone_mobile'
  </code></pre>
  
  <p>Actually it should through error message since ,both <code>phone_daytime</code> and <code>phone_mobile</code> are declared as <code>IntegerField</code>.But this giving the above error.Need help.</p>
  
  <p>Thanks</p>