开发者

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);
0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜