Created
March 22, 2013 18:08
-
-
Save reimund/5223472 to your computer and use it in GitHub Desktop.
Allows passing extra_context to ListView.as_view().
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
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