title: Django QueryDict (request.GET) is empty when I try to pass data from the template to the view
body: <p>Answered in comments. I removed this line: <code>url(r'^$', RedirectView.as_view(url='/1')),</code> and everything magically worked like it is suppose to!</p>
  
  <hr>
  
  <p>So the idea is that a user will click a button. That button will call a JavaScript function. That function will then submit a form. The form will call a certain function in <code>views.py</code>. </p>
  
  <p><strong>urls.py</strong></p>
  
  <pre><code>urlpatterns = [
      url(r'^[0-9]*$', main, name='main'),
  ]
  </code></pre>
  
  <p><strong>index.html</strong></p>
  
  <pre><code>&lt;form action="{% url 'main' %}" method="GET" id="myForm"&gt;
      &lt;input type="hidden" name="my_data" value="myValue"&gt;
  &lt;/form&gt;
  
  &lt;button href="javascript:{}" onclick="callMain();"&gt;main&lt;/button&gt;
  </code></pre>
  
  <p><strong>index_script.js</strong></p>
  
  <pre><code>function callMain(){
      document.getElementById("myForm").submit();
  }
  </code></pre>
  
  <p><strong>views.py</strong></p>
  
  <pre><code>def main(request):
      print(request.GET) #empty dict  &lt;QueryDict: {}&gt;
  
      #data = request.GET['my_data'] #&lt;------ doesn't work.
      #data = request.GET.get('my_data', '') #doesn't throw error, but still empty.
  
      return render( ......."settings.html",  {'name': data})
  </code></pre>
  
  <p>Below is the output in the terminal when the button is clicked:</p>
  
  <pre><code>[31/Mar/2016 23:17:06] "GET /?my_Data=myValue HTTP/1.1" 302 0
  </code></pre>
  
  <hr>
  
  <p>Everything works properly except for the part where <code>request.GET</code> is empty. Where are my errors? </p>
  
  <hr>
  
  <p>EDIT:</p>
  
  <p><code>index.html</code> is rendered like this:</p>
  
  <pre><code>return render(request, "index.html", {'someContext': "value"})
  </code></pre>
  
  <p>Here is more of the runserver output: </p>
  
  <pre><code>[01/Apr/2016 00:46:47] "GET /static/img/1.png HTTP/1.1" 304 0
  [01/Apr/2016 00:46:48] "GET /?my_data=myValue HTTP/1.1" 302 0
  &lt;QueryDict: {}&gt;
  
  [01/Apr/2016 00:46:48] "GET /1 HTTP/1.1" 200 2246
  </code></pre>
  
  <p>I believe Line 1 is fetching the image. Line 2 is when I click the button. Line 3 is the print statement in <code>main()</code> function. And the final line is the render call at the end of <code>main()</code>. </p>
  
  <hr>
  
  <p>Complete <code>views.py</code></p>
  
  <pre><code>import re
  
  from django.shortcuts import render
  from MyImage.models import MyImage
  
  
  
  
  def main(request):
  
      print(request.GET)
  
      image_file = get_image_file(request)
  
      if (MyImage.objects.filter(name=image_file).exists()):
  
          image = MyImage.objects.get(name=image_file)
          image.view_count = image.view_count + 1
          image.save()
  
          return render(request, "index.html", {'image': "img/"+image_file})
      else:
          return render(request, "index.html", {'image': "img/1.png"})
  
  
  def get_image_file(request):
      i = request.get_full_path()
      i = re.sub("[^0-9]", "", i)
      image_file = i + ".png"
      return image_file
  </code></pre>
  
  <p>Images are stored as <code>1.png</code>, <code>2.png</code>, <code>3.png</code>, etc. So if a user went to www.mysite.com/2, then they should see <code>2.png</code>. If the picture doesn't exist, then the default picture is shown instead.</p>
  
  <hr>
  
  <p>Complete <code>urls.py</code></p>
  
  <pre><code>from django.conf.urls import include, url
  from django.contrib import admin
  from .views import main
  from django.views.generic import RedirectView
  
  
  
  urlpatterns = [
      url(r'^$', RedirectView.as_view(url='/1')),
      url(r'^admin/', include(admin.site.urls)),
      url(r'^[0-9]*$', main, name='main'),
  
  ]
  </code></pre>