#28331: extra_context argument on TemplateView.as_view
-----------------------------------------+------------------------
               Reporter:  Jeremy         |          Owner:  nobody
                   Type:  Uncategorized  |         Status:  new
              Component:  Uncategorized  |        Version:  1.11
               Severity:  Normal         |       Keywords:
           Triage Stage:  Unreviewed     |      Has patch:  0
    Needs documentation:  0              |    Needs tests:  0
Patch needs improvement:  0              |  Easy pickings:  0
                  UI/UX:  0              |
-----------------------------------------+------------------------
 It used to be possible to pass extra_context to direct_to_template.  Then
 direct_to_template was replaced with TemplateView.as_view ... but the
 latter function never got the ability to take an extra_context arg.

 As a result there are now half a trillion (rough estimate) re-
 implementations of the following:


 {{{
 class StaticPageView(TemplateView):
     context = None

     def get_context_data(self, **kwargs):
         context = super(StaticPageView, self).get_context_data(**kwargs)
         context.update(self.context or {})
         return context


 }}}
 You can find them across the web, across StackOverflow, etc.  Everyone has
 to make this one stupid class just so that they can pass an extra context
 to template-only views.

 This is counter-productive: the whole point of a framework is to *prevent*
 everyone from having to re-invent the same code.  Adding yet another re-
 implementation of StaticPageView does nothing to improve the code, it only
 clutters it up with boilerplate.

 Please fix this by allowing as_view to take an extra_context arg

--
Ticket URL: <https://code.djangoproject.com/ticket/28331>
Django <https://code.djangoproject.com/>
The Web framework for perfectionists with deadlines.

-- 
You received this message because you are subscribed to the Google Groups 
"Django updates" group.
To unsubscribe from this group and stop receiving emails from it, send an email 
to [email protected].
To post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/055.bee14552d9c3cd00bf9069fdc3498fc3%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to