title: want to improve my view
body: <p>I've view like this. It worked. I'm new to django. Can you please help me to improve this code? thank you</p>
  
  <pre><code>def getAPI(request):
      username = request.GET.get('username')
      password = request.GET.get('password')
      #TODO Match user and password
      if username:
          user = User.objects.get(username__exact=username)
          is_exist = user.check_password(password)
          if is_exist == True:
              api_key = ApiKey.objects.get(id=user.id)
          else:
              error_message = 'username or password is invalid.'
      return render_to_response('details.html',locals(),
                          context_instance=RequestContext(request)
                          )
  </code></pre>
  
  <p>if username and password does not exist Then I want to print <code>error message</code>. Otherwise I want to print <code>ApiKey</code>. thanks</p>