Rendering another template from a button click in Django

I have following template files in my django project:

  1. base.html
  2. base_test1.html
  3. base_test2.html

Here both base_test1.html and base_test2.html extends base.html. My home page renders base_test1.html. In my home page, I have a button which when pressed should render base_test2.html. How should I achieve this?

I have been trying to use jQuery ajax call so that when the button is pressed, I call the corresponding view in the of my application. But that doesn't seem to be working since the ajax call just returns the html page to the request rather than rendering it.


  • Create another url, view for 2nd template which I think you have done.
  • Make button as link to this url. So that when the button is pressed, page with 2nd template is rendered.

If you want to use ajax, the base_test2.html should not return complete HTML page. But just some block in the html page, which you replace in the original page.

Need Your Help

Class with general and specialized attributes

c++ design-patterns design configuration

How to model a class with general and specific attributes based on type. For example I have a Primitive class. The Primitive class has the following general members : PrimitiveType, translation,

How to show Android's xml file in wordpress?

android xml wordpress-plugin

I am writing a blog about Android by WP-CodeBox plugin and want to add a layout.xml into blog like this:

About UNIX Resources Network

Original, collect and organize Developers related documents, information and materials, contains jQuery, Html, CSS, MySQL, .NET, ASP.NET, SQL, objective-c, iPhone, Ruby on Rails, C, SQL Server, Ruby, Arrays, Regex, ASP.NET MVC, WPF, XML, Ajax, DataBase, and so on.