[Answered ]-Dynamic (JS/Ajax) field updates w/ Django admin interface


You can customize the template that Django admin uses for your particular model. You don’t have to write the whole template, instead, you can juste add the bunch of javascript that you need inside a {% block extrahead %} template tags. And use jQuery to set your event handling. Django use jQuery in the admin interface under django.jQuery.

In order for django to find your custom template, you have to place it in the right place.
Take a look at the section Customizing Admin Templates here : http://www.djangobook.com/en/1.0/chapter17/

Here is juste a short example :

{% block extrahead %}

<script type="text/javascript" src="{{ ADMIN_MEDIA_PREFIX }}jquery.min.js"></script>

<script type="text/javascript">
  django.jQuery(function($) {
    // set your handlers, etc.
{% endblock %}

Leave a comment