title: matching query does not exist Error in Django
body: <p>I have implemented a password recovery functionality in django. With my method, the new password will be sent to the email id entered. It works fine when given the correct email (e-mail id which exists in the database). But when given an email id which is not in the database, it gives the error:<br />
  <code>'DoesNotExist at /forgotPassword/  UniversityDetails matching query does not exist.'</code></p>
  <p>How can I resolve this issue?</p>
  <p><strong>forgotPassword.html()</strong></p>
  <pre><code>def forgotPassword(request):
      if request.POST:
          email=request.POST.get(&quot;email&quot;)
          user = UniversityDetails.objects.get(email=email)
          if(not user):
              print &quot;No user&quot;
              return render_to_response(&quot;forgotPassword.html&quot;)
          else:
              newPassword = user.password
              send_mail('Password Recovery', 'The password for your site is '+ newPassword, 'rv_nair@gmail.com',
      ['rv_ks@gmail.com'], fail_silently=False)   
              return render_to_response(&quot;passwordRecovery.html&quot;)
      return render_to_response('forgotPassword.html')
  </code></pre>
  <p><strong>html</strong></p>
  <pre><code>&lt;form name=&quot;forgotPassword&quot; method=&quot;POST&quot; id=&quot;myFormid&quot; action=&quot;http://10.1.0.90:8080/forgotPassword/&quot;&gt;
  &lt;div style=&quot;float:center;width:100%;color:#0000A0&quot;&gt;
   Enter your E-mail ID&lt;/label&gt;&lt;br/&gt; &lt;input type=&quot;text&quot; name=&quot;email&quot; size=&quot;25&quot; /&gt; 
   &lt;input type=&quot;submit&quot; value=&quot;Submit&quot; /&gt;
   &lt;/div&gt; 
  
  &lt;/form &gt;
  </code></pre>