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?
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..
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With