title: How to check if requested data exist
body: <p>I have a problem with data support. I pass in template different names of variables. When I send one variable I've got error: Exception Type:   MultiValueDictKeyError.</p>
  
  <p>I send to view variables named <code>btn</code>, <code>delete</code> and <code>undo</code>.</p>
  
  <p>I've done it in this way</p>
  
  <pre><code>try:
         task = List.objects.get(id=data['undo'])
     except:
         try:
             task = List.objects.get(id=data['delete'])
         except.....
  </code></pre>
  
  <p>And that is working properly but I've got a challenge to do it in a better way.</p>
  
  <p>There is my view</p>
  
  <pre><code>def index(request):
      if request.method == 'POST':
          data = request.POST
          type_of = request.POST.get('type')
          if data['description']:
              new_task = List()
              new_task.create_task(data['title'], data['description'], type_of)
          else:
              return render(request, './index.html', {'context': "error: field cannot be empty"})
      if request.method == 'GET':
          data = request.GET
          try:
              task = List.objects.get(id=data['btn'])
              for x in task_status:
                  if task.type_of == task_status[x]:
                      task.type_of = task_status[x + 1]
                      break
              task.save()
          except:
              try:
                  task = List.objects.get(id=data['delete'])
                  task.delete()
              except:
                  try:
                      task = List.objects.get(id=data['undo'])
                      for x in task_status:
                          if task.type_of == task_status[x]:
                              task.type_of = task_status[x - 1]
                              break
                      task.save()
                  except:
                      task_list_back_log, task_list_to_do, task_list_in_progress, task_list_done = return_filter_lists()
                      return render(request, './index.html',
                                    {'back_log': task_list_back_log, 'to_do': task_list_to_do,
                                     'in_progress': task_list_in_progress,
                                     'done': task_list_done})
  </code></pre>
  
  <p>But when I deleted my try-except block and pass to view for example only <code>data['undo']</code> I've got error </p>
  
  <blockquote>
    <p>Exception Value: 'btn'</p>
  </blockquote>
  
  <p>The problem is that when i load template first time my data query is empty...
  Is there any way to check which variable exists in view and use it?</p>