4

I need to write a DetailView in Django. I achieved this functionality. However, I need to add some more data along with the context object. How will I achieve this.

My generic view is:

class AppDetailsView(generic.DetailView):
    model = Application
    template_name = 'appstore/pages/app.html'
    context_object_name = 'app'

I need to add one more variable to the context object:

response = list_categories(storeId)
deltaforce
  • 524
  • 1
  • 8
  • 25

1 Answers1

12

How about using get_context_data

class AppDetailsView(generic.DetailView):
     model = Application
     def get_context_data(self, **kwargs):
        context = super(AppDetailsView, self).get_context_data(**kwargs)
        context['categories'] = list_categories(storeId)
        return context
burning
  • 2,426
  • 6
  • 25
  • 38