Consider the Models class definition: In models.py,
class Classroom(models.Model):
subject1 = models.CharField(maX_length=80)
subject2 = models.CharField(maX_length=80)
class Student(models.Model):
name = models.CharField(maX_length=80)
classroom = models.ForeignKey(Classroom)
I am inheriting django's admin change_form.html template for the Student model. I need to access subject1 and subject2 attributes which I can do with {{ adminform.form.instance.classroom.subject1 }} and the same with subject2. But how do I access these values in the javascript of this form? Based on the value I want to hide/show some value. I don't want to use a custom view/template for this, where I could pass context variables. Can this be achieved?