title: Django : HTML form action directing to view (or url?) with 2 arguments
body: <p>Started learning django about a week ago and ran into a wall. Would really appreciate any enlightenment...</p>
  
  <p>models.py</p>
  
  <pre><code>class data(models.Model):
      course = models.CharField(max_length = 250)
  
      def __str__(self):
          return self.course
  </code></pre>
  
  <p>html</p>
  
  <p>Converted the objects in models.course to schlist</p>
  
  <pre><code>&lt;link rel="stylesheet" type="text/css" href="{% static '/chosen/chosen.css' %}" /&gt;
  &lt;form action={% views.process %}  method="GET"&gt;
        &lt;div&gt;
          &lt;h4 style="font-family:verdana;"&gt;First Course: &lt;/h4&gt;
          &lt;select data-placeholder="Course" style="width:350px;" class="chosen-select" tabindex="7"&gt;
            &lt;option value=""&gt;&lt;/option&gt;
            {% for item in schlist %}
            &lt;option&gt; {{ item }} &lt;/option&gt;
            {% endfor %}
          &lt;/select&gt;
        &lt;/div&gt;
        &lt;/br&gt;
        &lt;div&gt;
          &lt;h4 style="font-family:verdana;"&gt;Second Course:&lt;/h4&gt;
          &lt;select data-placeholder="Course" style="width:350px;" class="chosen-select" tabindex="7"&gt;
            &lt;option value=""&gt;&lt;/option&gt;
            {% for item in schlist %}
            &lt;option&gt; {{ item }} &lt;/option&gt;
            {% endfor %}
          &lt;/select&gt;
        &lt;/div&gt;
        &lt;/br&gt;
    &lt;input type="submit" value="Compare!" /&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>urls.py (having my doubts if this works..)</p>
  
  <pre><code>urlpatterns = [
      url(r'^(\d+)/(\d+)$',views.process, name = 'process'),
  ]
  </code></pre>
  
  <p>view.py</p>
  
  <pre><code>def process(request,q1 ,q2):
      obj1= get_object_or_404(Schdata, course = q1)
      obj2= get_object_or_404(Schdata, course = q2)
   ........
  </code></pre>
  
  <p>Was wondering if it is possible for the form action to direct the action to</p>
  
  <p>(1) view.py or (2) url.py (and eventually to a view.py) with 2 arguments selected?</p>
  
  <p>If so how should the form action  be? {{view ?}} or {{url ?}}. Am I missing out the definition of my arguments in my HTML? </p>
  
  <p>Directing to views.py:</p>
  
  <p>User input is <code>CharField</code>, could use <code>get_object_or_404</code> to get the model pk. However when defining my urls.py I would get a Noreverse error as my url arguments is the primary key.</p>
  
  <p>Directing to urls.py:</p>
  
  <p>Url arguments is primary key. From the way I see it, I need to magically convert my User input <code>Charfield</code> to a pk before passing it to urls.py</p>
  
  <p>Is there a (or) function for <code>get()</code> in django? E.g <code>get_object_or_404(pk = q1 or course = q1)</code>?</p>
  
  <p>Would really appreciate any advice. Been staring at this for hours.</p>