#27289: Docs: Badly wrong explanation of View.as_view() and its use in urlconf
--------------------------------+-------------------------
     Reporter:  Graham Wideman  |      Owner:  nobody
         Type:  Bug             |     Status:  new
    Component:  Documentation   |    Version:  1.10
     Severity:  Normal          |   Keywords:  CBV as_view
 Triage Stage:  Unreviewed      |  Has patch:  0
Easy pickings:  1               |      UI/UX:  0
--------------------------------+-------------------------
 In the Introduction to class-based view (for example,
 https://docs.djangoproject.com/en/1.10/topics/class-based-views/intro/)
 the explanation for the as_view() method is wrong in a way which
 undermines clear understanding of a crucial piece of the CBV apparatus.

  Existing narrative: "Because Django’s URL resolver expects to send the
 request and associated arguments to a callable function, not a class,
 class-based views have an as_view() class method which serves as the
 callable entry point to your class. The as_view entry point creates an
 instance of your class and calls its dispatch() method."

 The as_view() class method is NOT the entry point and does NOT instantiate
 your class. If as_view() were the entry point, then its use in urlpatterns
 would omit the function brackets, and the subsequent Note about setting
 class attributes would make no sense.

 The narrative should be changed to something more like:

  "Django’s URL resolver expects to send the request and associated
 arguments to a callable function (as it does for function-based views),
 and so will not accept a class as the view argument in the url() function.
 Consequently, the View base class provides the as_view() class method
 which *returns a class method* that serves as the callable entry point to
 your class. Note that the as_view() function itself is *not* the entry
 point per se.   The function that as_view() returns (called later by the
 URL resolver when a request arrives for a URL matching the associated
 pattern) is responsible for instantiating your actual view class, and
 calling its dispatch() method."

--
Ticket URL: <https://code.djangoproject.com/ticket/27289>
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 post to this group, send email to [email protected].
To view this discussion on the web visit 
https://groups.google.com/d/msgid/django-updates/051.71a90c2ad9e4a3bfa0b816ffbbcf3243%40djangoproject.com.
For more options, visit https://groups.google.com/d/optout.

Reply via email to