Reputation: 1254
I am using Django 1.7 and have a model admin with 2 textboxes. How can I listen to onchange event on the first one and update the second one?
Upvotes: 5
Views: 2813
Reputation: 37856
define a form in admin.py
class YourForm(forms.ModelForm):
class Media:
js = ('//code.jquery.com/jquery-1.11.0.min.js', 'js/custom_admin_validate.js')
class YourAdmin(admin.ModelAdmin):
form = YourForm
#..
and now, in custom_admin_validate.js
you can play with jquery in your adminpage.
please note, you may also want clean
method of form to validate further in backend..
Upvotes: 4