Thanks, Melvyn Sopacua,
Now it all makes sense.
On Saturday, 10 June 2017 21:54:57 UTC+5:30, Melvyn Sopacua wrote:
>
> On Saturday 10 June 2017 08:22:20 Ajat Prabha wrote:
>
>
>
>
>
> > class TopicDetailView(generic.DetailView):
>
> > > model = Topic
>
> > > context_object_name = 'topic'
>
> >
On Saturday 10 June 2017 08:22:20 Ajat Prabha wrote:
> class TopicDetailView(generic.DetailView):
> > model = Topic
> > context_object_name = 'topic'
> > template_name = 'topicdetail.html'
>
> def get_context_data(self, **kwargs):
> > context = super(TopicDetailView,
> >
See "reverse lookup" or "_set" function in order to do that.
Your Answer model has a FK for the Topic, but not the other way around.
See
https://developer.mozilla.org/en-US/docs/Learn/Server-side/Django/Generic_views,
"Creating the Detail View template" for details about it, there are some
li
Hi there,
I'm having trouble in filtering objects of a model based on another model's
foreign key. The scenario is, I've got a forum homepage and when a topic is
clicked, it opens its DetailView. Now if I try to get all answers in the
database there's no issue, but I want to get only the answers
4 matches
Mail list logo