Django - How to pass onclick_attrib to Models in Admin site
In Django Admin interface, Whenever there is a change in a specific field of a Model, I just need to ask the confirmation using JS. I fou开发者_StackOverflow社区nd that {{ onclick_attrib }} can achieve this. Can you please suggest from where we can pass this value? Is there any doc available?
I would simply include js file and do the stuff there.
Model definition:
class MyModelAdmin(admin.ModelAdmin):
class Media:
js = ('/js/my.js',)
And js (preview only):
(function($){
$(function(){
$("#id_field_name").change(function(){
return confirm("???");
});
})
})(django.jQuery);
精彩评论