On Monday, 13 March 2017 18:36:46 UTC, Frederik Creemers wrote: > > Django views are just functions that take a request, and possibly some > other args, and return a response. To get such a view from a class based > view, you can `as_view()` on it. Why is that? Wouldn't it make the code > neater to just implement `__call__` on the views? What was the reing behind > having `as_view`? >
A search in django-developers would probably reveal the extremely long-running thread that led to that specific implementation. But, briefly, allowing the CBVs to be instantiated in the URLs would render them non-thread safe. Any attribute set on the object would persist across all future requests, leading to information leakage and other very bad behaviour. The `as_view()` construct is a (mostly successful) effort to make it almost impossible to break the thread safety of the view objects. -- DR. -- You received this message because you are subscribed to the Google Groups "Django users" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. To post to this group, send email to [email protected]. Visit this group at https://groups.google.com/group/django-users. To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/1b6323e5-ca93-4ccf-91d5-da7d5a72f6b7%40googlegroups.com. For more options, visit https://groups.google.com/d/optout.

