Created
September 17, 2011 12:01
-
-
Save amccloud/1223874 to your computer and use it in GitHub Desktop.
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
class ProjectMixin(object): | |
project_url_pk = 'project_id' | |
project = None | |
def dispatch(self, request, *args, **kwargs): | |
self.project = get_object_or_404(Project, pk=kwargs.get(self.project_url_pk)) | |
return super(ProjectMixin, self).dispatch(request, *args, **kwargs) | |
def get_context_data(self, **kwargs): | |
context = super(ProjectMixin, self).get_context_data(**kwargs) | |
context.update({'project': self.project}) | |
return context | |
class MilestonesView(ProjectMixin, generic.ListView): | |
model = models.Milestone |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment