#6735: Class-based generic views
------------------------------------+---------------------------------------
          Reporter:  jkocherhans    |         Owner:  telenieko
            Status:  assigned       |     Milestone:  1.2      
         Component:  Generic views  |       Version:  SVN      
        Resolution:                 |      Keywords:           
             Stage:  Accepted       |     Has_patch:  1        
        Needs_docs:  1              |   Needs_tests:  0        
Needs_better_patch:  0              |  
------------------------------------+---------------------------------------
Comment (by telenieko):

 Replying to [comment:37 mmalone]:
 > I've seen two methods of implementing class-based views, `__call__`
 based and `__init__` based. The attached patch uses the `__call__`
 approach. Here's a quick example of an `__init__` based class-view:

 Hi mmalone,
 This is getting a major re-thing/re-write by Jacob, taking an approach
 much more like Model classes, if I remember correctly, the thing was
 something like:

 {{{
 #!python
 from django.views.generic import ListView

 class MyListView(ListView):
     # Base view for views that list objects
     queryset = MyModel.objects.all()
     paginate_by = 30
     # You may override some methods here.
 }}}
 Then you'd pass the MyListView class to the URL patterns. __init__() would
 get URL parameters, while view configuration (what the current code here
 passes to __init__() would be on the class definition.

 It's much more like Model classes, the only drawback is that you need to
 define you view class even for really simple stuff. But complex things get
 much nicer ;)

 Hope Jacob can push current code sometime soon for everyone to see.

 Thanks for commenting!

-- 
Ticket URL: <http://code.djangoproject.com/ticket/6735#comment:38>
Django <http://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 [email protected]
To unsubscribe from this group, send email to 
[email protected]
For more options, visit this group at 
http://groups.google.com/group/django-updates?hl=en
-~----------~----~----~----~------~----~------~--~---

Reply via email to