Make your life a little easier and add a related_name argument to your Roll_No foreign key.

Example:
Roll_No = models.ForeignKey('Student_Info',to_field='Roll_No', related_name = 'students')

Then:

    obj.students.all()[0].E_mail

Without a related name:

obj.student_set.all()[0].E_mail


Note:
If it's a one-to-one relationship then you should use a OneToOne instead of a ForeignKey. That will allow something like this:

    obj.studient.E_mail


--
You received this message because you are subscribed to the Google Groups "Django 
users" group.
To post to this group, send email to [email protected].
To unsubscribe from this group, send email to 
[email protected].
For more options, visit this group at 
http://groups.google.com/group/django-users?hl=en.

Reply via email to