Correct :) On Sunday, 19 August 2012 20:44:11 UTC+1, Bernardo wrote: > > So as long as I don't use the `params` thing (which I don't) there will be > no problem with my views? > Reading this and the other commit done at the same time, looks like the > function calls behave the way I expect :) > > Bernardo > > Em domingo, 19 de agosto de 2012 06h44min03s UTC-3, Marc Tamlyn escreveu: >> >> Hi Bernado, >> >> Template view passing params into the context rather than just passing >> the kwargs from the urlconf directly is actally somewhat older, and is kept >> as legacy from django.views.generic.simple.direct_to_template. The changes >> you refer to do actually introduce a subtle backwards incompatibility with >> TemplateView - but yesterday we made a new commit[1], fixing the *real* >> problem, which is that the params variable was inconsistent with how the >> rest of the CBVs worked. This actually introduces a slightly different >> backwards incompatibility, which is that the params variable no longer >> exists. This has been documented in the release notes. >> >> There is perhaps a case for removing this passing of urlconf kwargs to >> the context all together, as it seems a little odd to me and only applies >> to TemplateView, but for the moment it's at least been made a bit more >> consistent with how other CBVs work. >> >> Marc >> >> [1] >> https://github.com/django/django/commit/f04bb6d798b07aa5e7c1d99d700fa6ddc7d39e62 >> >> On Saturday, 18 August 2012 08:21:28 UTC+1, Bernardo wrote: >>> >>> Hi, I was trying my project on django 1.5 alpha and a change on >>> TemplateViews made some code break. >>> The `get` method changed how `get_context_data` is called from >>> (**kwargs) to (params=kwargs). Link: >>> https://github.com/django/django/blob/master/django/views/generic/base.py >>> >>> I traced the change and found a ticket saying the TemplateView could not >>> be used with FormView because the get_context_data is in a different >>> layout. Ticket: https://code.djangoproject.com/ticket/16074 >>> >>> I don't know how popular are classed based views among other django >>> developers, but I only use them. So, this change could be added in the >>> release notes to warn people about breaking some code. >>> For me, I had the habit of writing: >>> >>> With e.g. this url: url(r'^ref/(?P<id>\d+?)/?$', >>> views.ref.Show.as_view()) >>> >>> def get_context_data(self, id, **kw): >>> pass #do something with id >>> >>> Now, the only way I find to keep the code compatible with both 1.4 and >>> 1.5 is doing: >>> >>> def get_context_data(self, **kw): >>> id = kw.get('params', kw)['id'] >>> >>> which is just a little bit more code but could crash in django 1.4 if >>> somehow there's a "params" argument >>> >>> Could this be avoided? >>> >>> Thanks, >>> Bernardo >>> >>
-- You received this message because you are subscribed to the Google Groups "Django developers" group. To view this discussion on the web visit https://groups.google.com/d/msg/django-developers/-/wDgBjSVJVtcJ. To post to this group, send email to django-developers@googlegroups.com. To unsubscribe from this group, send email to django-developers+unsubscr...@googlegroups.com. For more options, visit this group at http://groups.google.com/group/django-developers?hl=en.