Django: how to switch to another view with the click of a button?
<p>I am building a django app using django 1.9.5 and Python 2.7.11. My project (which I named djan_web) directory looks like the following:</p>

<pre><code>djan_web\
    manage.py
    djan_frontend\
        views.py
        templates\
            djan_frontend\
                upload.html  
                djan_homepage\
                       index.html
    djan_web/
        urls.py
</code></pre>

<p>I am able to load <code>index.html</code>, which is my homepage here. In <code>index.html</code>, I have a button, which when clicked, I would like to load <code>upload.html</code>. Here are my the relevant files:</p>

<p><code>index.html:</code></p>

<pre><code>&lt;!DOCTYPE html&gt;
&lt;html&gt;
  &lt;head&gt;
  &lt;title &gt;Django Wed Project&lt;/title&gt;
  &lt;meta http-equiv="Content-Type" content="text/html;charset=utf-8"/&gt;
  &lt;/head&gt;
  &lt;body&gt;
    &lt;div class="header"&gt;
    &lt;p&gt; some text &lt;/p&gt;

    &lt;div class="container" style="width:95%"&gt;

    &lt;center&gt;
       &lt;div class="col-md-1 center-block text-center" style="font-size: xx-large"&gt;
       &lt;a href="/upload-file" class="dark" style="cursor: pointer;"&gt;
        &lt;span class="glyphicon glyphicon-upload"&gt;&lt;/span&gt;Let's get started!&lt;/a&gt;
      &lt;/div&gt;
    &lt;/center&gt;
   &lt;/div&gt;
   &lt;/div&gt;
  &lt;/body&gt;
&lt;/html&gt;
</code></pre>

<p><code>urls.py:</code></p>

<pre><code>from django.conf.urls import include, url
from django.contrib import admin
from djan_frontend import views
from django.views.generic import TemplateView

urlpatterns = [
    url(r'^', views.homepage, name="homepage"),
    url(r'^admin/', admin.site.urls),
    url(r'^upload-file/$', views.upload, name='upload')
]
</code></pre>

<p><code>views.py:</code></p>

<pre><code>from django.http import HttpResponseRedirect
from django.shortcuts import render
from django.core.urlresolvers import reverse

from .upload_file import UploadFileForm
from .models import Document
from .tasks import process_csv

def homepage(request):
    return render(request, 'djan_frontend/djan_homepage/index.html')

def upload(request):
    return render(request, 'djan_frontend/upload.html')
</code></pre>

<p>I am able to load <code>index.html</code>, but when I click the button <code>Let's get started</code> nothing happens except for the URL, where <code>upload-file/</code> gets appended to it.</p>

<p>I also tried using TemplateView, so I changed <code>href</code> part in the button definition to <code>href="{% url 'upload' %}"</code> and changed the third url pattern in <code>urls.py</code> to </p>

<pre><code>url(r'^upload/$', TemplateView.as_view(template_name='upload.html'), name='upload')
</code></pre>

<p>and deleted the <code>upload</code> function in <code>views.py</code> but I couldn't get it work. Any help is greatly appreciated!</p>