title: Django: HTML form submission
body: <p>I am trying to create a simple website, with a form containing 3 options, and when the form is submitted, it displays some text showing the chosen option.</p>
  
  <p>Here is what I have so far...</p>
  
  <p><strong>myapp/templates/myapp/index.html:</strong></p>
  
  <pre><code>&lt;!DOCTYPE html&gt;
  &lt;html&gt;
  &lt;body&gt;
  
  &lt;form method="get" action="{% url submit %}"&gt;
  &lt;input type="radio" name="which_choice" value="1"&gt;Choice 1&lt;br&gt;
  &lt;input type="radio" name="which_choice" value="2"&gt;Choice 2&lt;br&gt;
  &lt;input type="radio" name="which_choice" value="3"&gt;Choice 3&lt;br&gt;
  &lt;input type="submit" value="Submit"&gt;
  &lt;/form&gt; 
  
  &lt;/body&gt;
  &lt;/html&gt;
  </code></pre>
  
  <p><strong>myapp/views.py:</strong></p>
  
  <pre><code>from django.shortcuts import render
  
  def index(request):
      return render(request, 'myapp/index.html')
  
  def submit(request):
      if 'which_choice' in request.GET:
          message = 'The choice is: %r' % request.GET['which_choice']
      else:
          message = 'You submitted an empty form.'
      return HttpResponse(message)
  </code></pre>
  
  <p><strong>mysite/urls.py:</strong></p>
  
  <pre><code>from django.conf.urls import patterns, include, url
  
  urlpatterns = patterns('',
  url(r'^myapp/', include('myapp.urls')),
  )
  </code></pre>
  
  <p><strong>myapp/urls.py:</strong></p>
  
  <pre><code>from django.conf.urls import patterns, include, url
  
  from myapp import views
  
  urlpatterns = patterns('',
  url(r'^index', views.index, name='index'),
  url(r'^submit/$', views.submit, name='submit')
  )
  </code></pre>
  
  <p>However, I get a "Page not found at /submit" 404 error, when I submit the button from the index.html page. What am I doing wrong?</p>
  
  <p>Thanks.</p>