1👍
✅
User and UserProfile are two different models. But since you have a OneToOneField
from UserProfile
to User
, you can also follow it back.
<h1>User is {{ user }} from {{ user.userprofile.location }}</h1>
From the docs on OneToOneField
If you do not specify the related_name argument for the OneToOneField, Django will use the lower-case name of the current model as default value.
Source:stackexchange.com