#30698: `BaseDetailView` and `SingleObjectMixin` optimization.
-------------------------------------+-------------------------------------
     Reporter:  Davit Gachechiladze  |                    Owner:  Davit
         Type:                       |  Gachechiladze
  Cleanup/optimization               |                   Status:  closed
    Component:  Generic views        |                  Version:  master
     Severity:  Normal               |               Resolution:  wontfix
     Keywords:                       |             Triage Stage:
                                     |  Unreviewed
    Has patch:  1                    |      Needs documentation:  0
  Needs tests:  0                    |  Patch needs improvement:  0
Easy pickings:  0                    |                    UI/UX:  0
-------------------------------------+-------------------------------------
Changes (by Carlton Gibson):

 * status:  assigned => closed
 * resolution:   => wontfix


Comment:

 Hi Davit,

 Thanks for the suggestion. Strictly you're right, in theory this
 simplification is available. We can't make it, however.

 Firstly, they'll be plenty of folks that overrode `get_context_data()`
 relying on the fact that `self.object` is injected.
 (We change it, we break their code.)

 Then, removing relies too much on internal knowledge of the CBV
 implementations.

 The general pattern for `get_context_data()` is this:

 {{{
 def get_context_data(self, **kwargs):
     context = {
         # Some stuff...
     }

     # Allow caller to inject the values we want...
     context.update(kwargs)

     return context
 }}}

 Without looking at `SingleObjectMixin` at all, the implementation of
 BaseDetailView.get() is exactly what one want's: we want the calling
 function to ''drive'' `get_context_data() by passing in the object to be
 rendered.

 I don't know if you've seen them but check out http://django-vanilla-
 views.org/ for a stripped back take on GCBVs here.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/30698#comment:17>
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 django-updates+unsubscr...@googlegroups.com.
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/067.79b77e62925b2f16987de227fab3381f%40djangoproject.com.

Reply via email to