mysql - How to get primary key from another table with one-to-many relationship in embedded code in django -


i'm not sure how ask question, apologies in advance if doesn't make lot of sense.

i'm creating basic blogging-type website using pythonanywhere, , want each user have profile page. in page displays list of posts, have author of each post displayed in

{% post in posts %}:     <p>author: {{ post.author }}</p> 

assuming urls, views , templates fine, how add link text lead /accounts/[user's id]?

the post model's author field defined as

author = models.foreignkey('auth.user') 

essentially want:

<p>author: <a href="{% url 'account_detail' pk=user.pk %}">{{ post.author }}</a></p> 

but don't know how user.pk post.author.

assuming have model:

author=models.foreignkey('here enough model)

and foreignkey in model named post

for access id of table write:

post.author__pk 

by way better operation in view.py like:

value = post.objects.values('name', 'author__pk').filter(filter if necessary) 

Comments