Saturday, June 29, 2013

Change template block via AJAX


I have an application containing a topbar and rest is content area.

In my 'base.html', I've defined two blocks -

  {% block topbar %}{% endblock topbar %}
  {% block page_content %}
        {% block sidebar %}
        {% endblock sidebar %}
        {% block main %}
        {% endblock main %}
    {% endblock page_content %}

These two blocks are then overridden by child templates.
The topbar contains a search input. The search query is sent via AJAX, and the results are loaded in respective child blocks through client-side templating.

Now, I want that whenever user enters a search query for a user via a radio button instead of default, The block 'page_content' should get overridden by another template 'user_results.html'. ( I'll know it client-side itself )
This can be done by redirecting to a path like '/search/user/', but that would involve reloading of the page.
Is this possible via an AJAX request, and then the server would load another template which will replace the 'page_content' block without page refresh ?

Parin Porecha

say Kifflom! and look forward to 17.09.13 !

You received this message because you are subscribed to the Google Groups "Django users" group.
To unsubscribe from this group and stop receiving emails from it, send an email to
To post to this group, send email to
Visit this group at
For more options, visit

No comments:

Post a Comment