#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
-------------------------------------+-------------------------------------
Comment (by Davit Gachechiladze):
Replying to [comment:17 Carlton Gibson]:
> 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.
Thank you for explanation.
--
Ticket URL: <https://code.djangoproject.com/ticket/30698#comment:18>
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 view this discussion on the web visit
https://groups.google.com/d/msgid/django-updates/067.a3d3d9cdc325777fc278804511cf5cb1%40djangoproject.com.