title: How to handle form elements with get method in django when form in not submitted
body: <p>I am new to Django-python and trying to build a single page python-django website which submits form values to itself. But how to handle .get method when form is not submitted initially?</p>
  
  <p>Form:</p>
  
  <pre><code>&lt;form id="filters" action="{% url 'myapp:index' %}" method="GET"&gt;
  {% csrf_token %}
  &lt;label&gt;&lt;input type="checkbox" name="abc" value="abc" checked&gt;Include abc&lt;/label&gt;
  &lt;label&gt;&lt;input type="checkbox" name="pqr" value="pqr" checked&gt;Include abc&lt;/label&gt;
  &lt;label&gt;&lt;input type="checkbox" name="xyz" value="xyz" checked&gt;Include abc&lt;/label&gt;
  &lt;input type="submit" value="Submit"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>Views.py:</p>
  
  <pre><code>from django.shortcuts import render
  
  def index(request):
      try:
          abc = request.GET['abc']
          context = {'abc':abc}
      except (KeyError):
          raise
      else:
          return render(request, 'myapp/index.html', context)
  </code></pre>
  
  <p>Now when I open index page initially for myapp, it raises </p>
  
  <blockquote>
    <p><strong>MultiValueDictKeyError</strong></p>
  </blockquote>
  
  <p>which I assume is because the checkboxes are not set initially.</p>
  
  <p>If I change abc = request.GET['abc'] to</p>
  
  <pre><code>abc = request.GET.get['abc']
  </code></pre>
  
  <p>It raises:</p>
  
  <blockquote>
    <p><strong>TypeError</strong><br>
    'instancemethod' object has no attribute '<strong>getitem</strong>'</p>
  </blockquote>
  
  <p>Traceback:</p>
  
  <blockquote>
  <pre><code>                response = middleware_method(request, callback, callback_args, callback_kwargs)
                  if response:
                      break
          if response is None:
              wrapped_callback = self.make_view_atomic(callback)
              try:
                              response = wrapped_callback(request, *callback_args, **callback_kwargs) ...
              except Exception as e:
                  # If the view raised an exception, run it through exception
                  # middleware, and if the exception middleware returns a
                  # response, use that. Otherwise, reraise the exception.
                  for middleware_method in self._exception_middleware:
                      response = middleware_method(request, e)
  </code></pre>
  </blockquote>
  
  <p>Stuck and not able to understand these errors.</p>
  
  <p>Can I do something like if(!isset($_POST['submit'])) like in PHP, so that my python script is not submitted until submit is pressed?</p>