M
M
mihzas2014-12-06 23:17:48
Django
mihzas, 2014-12-06 23:17:48

How to display in the author's template?

- Now I'm making a site like a chat,
- It has two models (Author, Post, and the author is associated with the Post model via ForeignKey),
- How to display both the author's name and the content of the post in the template

Answer the question

In order to leave comments, you need to log in

1 answer(s)
S
sim3x, 2014-12-06
@mihzas

<h1>{{ post.user.name }}
<div>{{ post.content }}

If a
class SomeUser(Model):
    name = CharField()
     #...


class Post(Model):
     user = ForeignKey(SomeUser)
     content = TextField()
     #...

Didn't find what you were looking for?

Ask your question

Ask a Question

731 491 924 answers to any question