[Django]-Django CBV DetailView – accessing the object to assign to a context variable?

5👍

In the DetailView, you’ll be able to access the object with self.object. Therefore you should do:

context['title'] = self.object.nick_name

However, you might find it easier to simply access the nickname via the object in the template:

{{ object.nickname }}

Leave a comment