so i have these 2 model
- Profile (have one to one relationship with my default django User model)
- Item ( also have one to one relationship with my default django User model) from Item model, how do i get access to Profile model using User model
please see my code below
My Model
class Profile(models.Model):
user = models.OneToOneField(User, on_delete=models.CASCADE)
phone = models.CharField(max_length=200,null=True) ```
My View
def home(request):
all_item_lists = Item.objects.all()
context = {
'all_item_lists':all_item_lists
}
return render(request, 'findit/home.html', context)
My Template
{% for list in all_item_lists %}
<!-- how want to get the phone number of the user that posted this Item -->
<span>{{list.owner.first_name }}</span>
{% endfor %}```