[Answered ]-How to call model in Django

1👍

You have only passed citizen into the context (you haven’t passed passport in the context). To access the related Passport of the citizen you can write citizen.sID (the name of your OneToOneField), hence in your template you can write:

<h2>Passport:</h2>

<ul>
    <li>Loại hộ chiếu: {{ citizen.sID.pType }} </li>
    <li>Số hộ chiếu: {{ citizen.sID.Number }}</li>
    <li>Thời hạn hiệu lực: {{ citizen.sID.validTime }}</li>
    
</ul>

Leave a comment