[Answered ]-How I can pass a model class attribute as a context from a class based view

1👍

You don’t have to pass the title to the context because it is already there.

In the template, you can access it with {{ object.title }}

Or

for some reason if you still wanted to override get_context_data, then you can use self.object.title,

def get_context_data(self, **kwargs):
     context = super().get_context_data(**kwargs)
     context['title'] = self.object.title
     return context

and in templates {{ title }}

Leave a comment