How to access other model's attribute in one model via Foreign key in django?
<pre><code>class Grade(models.Model):
    name = models.CharField(u'年级', max_length=64)
    school = models.ForeignKey('School', verbose_name=u'学校')

    def __unicode__(self):
        return self.name

class Class(models.Model):
    name = models.CharField(u'班级', max_length=64)
    grade = models.ForeignKey('Grade', verbose_name=u'年级', related_name='grade')

    def getGradeName(self):
        return self.grade.name

    def __unicode__(self):
        return self.name

class Student(models.Model):
    name = models.CharField(u'姓名', max_length=64)
    sex = models.CharField(u'性别', max_length=64)
    id_num = models.CharField(u'身份证号', max_length=64)
    student_num = models.CharField(u'学号', max_length=64)
    class_id = models.ForeignKey('Class', verbose_name=u'班级', related_name='class_id')
    grade = class_id.name

    def __unicode__(self):
        return self.name
</code></pre>

<p>I want to get students'class'grade and then assign it to grade in Model Student.</p>

<p>How to get Grade's name in model Student?</p>