How to change template names in django listview according to url request?
<p>I have 2 templates to render <strong>one</strong> listview and I am choosing the template according to the request url given by the user. I know that, I can add 2 classes for 2 templates on 2 seperate urls respectively. For example </p>

<pre><code>class MyListView1(generic.ListView):
     template_name = 'myapp/list_one.html'
     .....
     .....

class MyListView2(generic.ListView):
     template_name = 'myapp/list_two.html'
     .....
     .....
</code></pre>

<p>But is there a way if I could check the url request inside one class and render the template according to it inside one listview class ? something like</p>

<pre><code>class MyListView(generic.ListView):

   if request.path == '/list1'
         template_name = 'myapp/list_one.html'
   if request.path == '/list2'
         template_name = 'myapp/list_two.html'
</code></pre>

<p>I know this is not a valid code but just to visualise</p>