Tuesday, February 24, 2015

Re: Using class based views.

On Tue, Feb 24, 2015 at 1:51 AM, James Schneider
<jrschneider83@gmail.com> wrote:
> However, if you have working view functions, what is the"need" to switch to
> CBV's?


this.

the switch to CBV, wasn't "modern Django views are classes instead of
functions; Get rid of your functions!, FBV are dead!". Instead it's
just that _generic_ views weren't useful enough, and to make them more
extensively configurable, they were transformed into a very capable,
albeit complex, set of classes.

all this is just for the included generic views, for your own views
just do whatever you find appropriate to structure your code and, in
the end, present a callable to the url() routing structures.

If you have too much repeated code, by all means factor it out; either
into supporting functions, or turn your views into objects, or
classes, anything you like. But even if you decide to do some CBV,
there's no need to use the included classes, as they're unlikely to be
the best answer outside of the 'generic view' envelope.

--
Javier

--
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 django-users+unsubscribe@googlegroups.com.
To post to this group, send email to django-users@googlegroups.com.
Visit this group at http://groups.google.com/group/django-users.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-users/CAFkDaoR%2BPhV5mEAG%3DGWVnqcyRJbLBJ%2BnQUXdRJujED6RdKF-2w%40mail.gmail.com.
For more options, visit https://groups.google.com/d/optout.

No comments:

Post a Comment