TemplateView and FormView inconsistency

86 views
Skip to first unread message

step21

unread,
Aug 13, 2019, 9:58:48 PM8/13/19
to django-d...@googlegroups.com
Hi all,

When developing I noticed an inconsistency - when using TemplateView, kwargs are passed to context, but not when using FormView or others.

Source comparison:

https://dpaste.de/Jwdn

Relevant super old issue talking about depreciation here:
https://code.djangoproject.com/ticket/19878

I discussed this briefly on IRC and was told to post here, as it is an inconsistency and maybe should be fixed but maybe wasn’t for a reason. Seeing as there was already talk of depreciating it several years ago and no clear opposition, maybe I could prepare a patch for it?
Any thoughts?

F
signature.asc

Adam Johnson

unread,
Aug 14, 2019, 3:45:54 AM8/14/19
to django-d...@googlegroups.com
Hi,

After reading the ticket, I agree this could be deprecated as a backwards incompatibility. The deprecation plan suggested by loic84 looks like it could work but would be a bit unwieldy on large projects. Maybe there's another path?

One thing that's not explicitly in the discussion: the view kwargs are always accessible inside templates because ContextMixin.get_context_data passes 'view', and view.kwargs is always set by View.setup().

Thanks,

Adam

--
You received this message because you are subscribed to the Google Groups "Django developers  (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/5072B2EE-D2B4-448C-936D-C5FDB5CD7132%40devtal.de.


--
Adam

step21

unread,
Aug 14, 2019, 9:46:33 AM8/14/19
to django-d...@googlegroups.com
I do not have a better idea right now, but also do not know the django core code that well. Personally, as you could get all TemplateViews via Ack or another code search method, I do not think replacing them would take long.

signature.asc

Adam Johnson

unread,
Aug 15, 2019, 1:51:47 AM8/15/19
to django-d...@googlegroups.com
I came up with a PR that will raise a deprecation warning on variable access - see the ticket.



--
Adam
Reply all
Reply to author
Forward
0 new messages