Well, I don't mean that now we all must write only class-based views.
I was talking about reusable views and most views don't have to be
reusable (though it would be nice). Django now can help developer in
writing reusable views and it was not the case when TemplateResponse
was invented. That's what I mean with "TemplateResponse is less useful
now". TemplateResponse and class-based views are targeting the same
problem and they are different ways to solve it. I don't know what is
better, the argument was that we already have one way to reuse view
logic.

My statement about "only complicate things in django 1.3" was
premature, sorry. TemplateResponse is indeed a nice way to reuse view
logic that don't require writing a class-based view.

The ticket in DDN is http://code.djangoproject.com/ticket/12815.

So now the questions are:

1. Do we need 2 nice ways for reusing view logic (with and without
classes)? I don't have an opinion on this.
2. Does TemplateResponse allow pretty exception pages or not? Is Ben's
issue resolved?


On 21 окт, 13:25, Ivan Sagalaev <man...@softwaremaniacs.org> wrote:
> On 10/21/2010 11:10 AM, James Bennett wrote:
>
>
>
>
>
> > Django cares about whether your views meet the following criteria:
>
> > 1. Is a callable object.
> > 2. When called, accepts an instance of HttpRequest as its first
> > positional argument.
> > 3. When called, returns an instance of HttpResponse or raises an exception.
>
> > That's it. Write them as functions, if that makes sense for your use
> > case. Write them as classes with callable instances, if that makes
> > sense for your use case. Generic views are now class-based because
> > that's what seems to work best *for the case of generic views*;
> > subclassing and overriding is, for the type of flexibility the generic
> > views need, simpler and cleaner than supporting long lists of keyword
> > arguments. But the generic views are not all views, and not all views
> > have to do what the generic views do. So my position is that you
> > should think about what you need from your view, and choose
> > class-based or function-based as appropriate.
>
> Thanks, that what I thought.
>
> Going back to the argument about TemplateResponse I can say that it's a
> good way for a view-as-function to keep its response hackable.

-- 
You received this message because you are subscribed to the Google Groups 
"Django developers" group.
To post to this group, send email to django-develop...@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.

Reply via email to