Skip to content

Instantly share code, notes, and snippets.

@reimund
Created March 22, 2013 18:08
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save reimund/5223472 to your computer and use it in GitHub Desktop.
Save reimund/5223472 to your computer and use it in GitHub Desktop.
Allows passing extra_context to ListView.as_view().
from django.views.generic.list import ListView
class UsefulListView(ListView):
""" Allows passing extra_context to ListView.as_view(). """
extra_context = {}
def get_context_data(self, **kwargs):
context = super(UsefulListView, self).get_context_data(**kwargs)
context.update(self.extra_context)
return context
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment