title: Python - Django 2.0 - URL patterns, passing arguments
body: <p>I am writing a very basic web page in Python which has a text box where a user can type in a username, then hit the Ok button which submits a form using a GET request. The GET passes the username as an argument and searches the auth_user table in the database.</p>
  
  <p>My problem is I am not able to pass the username argument, please help if you can Django 2.0 url patterns</p>
  
  <p>urls.py</p>
  
  <pre><code>app_name = 'just_gains'
      urlpatterns = [
          path('lifecoaching', views.LifeCoach, name='life_coaching'),
          path('lifecoaching/resultslifecoaching/&lt;str:user_name&gt;', views.LifeCoachSearchResults, name='results_life_coaching'),
      ]
  </code></pre>
  
  <p>forms.py</p>
  
  <pre><code>class LifeCoachSearch(forms.Form):
      user_name = forms.CharField(label='Username', max_length=100, required = False)
  </code></pre>
  
  <p>views.py</p>
  
  <pre><code>def LifeCoach(request):
      if request == 'GET':
          form = LifeCoachSearch(request.GET)
          if form.is_valid:
              user_name = form.cleaned_data['user_name']
              LifeCoachSearchResults(request,user_name)
  
      else:
          form = LifeCoachSearch()
          return render(request, 'just_gains/life_coaching.html', {'form': form})
  
  def LifeCoachSearchResults(request, user_name):
  
      testUser = User.objects.filter(username__startswith=user_name)
      context = {'TestUser': testUser}
      return render(request, 'just_gains/results_life_coaching.html', context)
  </code></pre>
  
  <p>HTML (lifecoaching)</p>
  
  <pre><code>&lt;form action="{% url 'just_gains:results_life_coaching' %}" method="GET" &gt;
      {% csrf_token %}
      {{ form }}     
      &lt;input type="submit" value="OK"&gt;
  &lt;/form&gt;
  </code></pre>
  
  <p>HTML (resultslifecoaching)</p>
  
  <pre><code>&lt;ul&gt;
      &lt;li&gt;&lt;a&gt;print usernames that match the argument&lt;/a&gt;&lt;/li&gt;
  &lt;/ul&gt;
  </code></pre>