#16744: Class based view should have the view object in the context
---------------------------------------+-------------------------------
               Reporter:  reinout      |          Owner:  nobody
                   Type:  New feature  |         Status:  new
              Milestone:               |      Component:  Generic views
                Version:  1.3          |       Severity:  Normal
             Resolution:               |       Keywords:
           Triage Stage:  Accepted     |      Has patch:  0
    Needs documentation:  0            |    Needs tests:  0
Patch needs improvement:  0            |  Easy pickings:  0
                  UI/UX:  0            |
---------------------------------------+-------------------------------
Changes (by jezdez):

 * stage:  Unreviewed => Accepted


Old description:

> Summary: `your_cbv_object.get_context_dict()` should include `{'view':
> self}`.
>
> Now that django has class based views, I was surprised that I don't get
> the view object in my template's context. And that I still have to hand-
> craft my context dictionary.
>
> What would be handier than setting attributes or adding methods to the
> view class and accessing them with `{{ view.my_attribute }}` and ``{{
> view.my_method }}`? Without having to do the double work of adding them
> by hand to the context dictionary? An additional benefit: you encourage
> to do even more in python and even less in the template by making it easy
> to add helper methods in your view.
>
> The solution could as simple as adding `{'view': self}` in the three or
> four spots in django itself where a `.get_context_dict()` is defined.

New description:

 Summary: `your_cbv_object.get_context_data()` should include `{'view':
 self}`.

 Now that django has class based views, I was surprised that I don't get
 the view object in my template's context. And that I still have to hand-
 craft my context dictionary.

 What would be handier than setting attributes or adding methods to the
 view class and accessing them with `{{ view.my_attribute }}` and ``{{
 view.my_method }}`? Without having to do the double work of adding them by
 hand to the context dictionary? An additional benefit: you encourage to do
 even more in python and even less in the template by making it easy to add
 helper methods in your view.

 The solution could as simple as adding `{'view': self}` in the three or
 four spots in django itself where a `.get_context_data()` is defined.

--

Comment:

 Corrected `get_context_dict` to `get_context_data`.

-- 
Ticket URL: <https://code.djangoproject.com/ticket/16744#comment:2>
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 post to this group, send email to django-updates@googlegroups.com.
To unsubscribe from this group, send email to 
django-updates+unsubscr...@googlegroups.com.
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en.

Reply via email to