Sunday, November 11, 2012

Re: How many developers have moved to class-based views?

-----BEGIN PGP SIGNATURE-----
Version: GnuPG v1.4.11 (GNU/Linux)

iEYEARECAAYFAlCf8j0ACgkQuYLL1cDjHx15CQCeNWa5aBLwrIQCyYrW8jJt9IDR
jZcAn23PNr39BfvQt0jtp+IbSEvSRxjg
=d0R3
-----END PGP SIGNATURE-----
On Sun, 11 Nov 2012 09:57:16 -0800 (PST) Kevin <kveroneau@gmail.com>
wrote:
> Hello!
>
> I am curious of how many existing Django developers have moved over
> to class-based views or are still using the function-based ones. I
> tend to use a mix depending on what I am trying to do. I try to
> stick with class-based views, but fallback to function-based ones for
> process-based views, views which don't return a template but redirect
> after processing some end-user action.

Docs on CBV in django1.4 are a bit sparse to say the least.

And we started the project before there where CBV.

But we are using CBV for some stuff already, deriving a
JqtableAjaxView from the documentations AjaxView has saved us quite
some code. And simplified testing.
there are other occasions where CBV would result in more code, so we
don't use it there...

One of our greatest problems is that you can't use permission
decorators as easily as with function-views. But on one hand I just
learned about the Mixins of django-braces. And on the other hand most
of our views need object-based permissions with a much more
sophisticated permission model than just users and groups. So we are
doing a lot ourselves and only provide an auth-backend to get our
permissions into the django-mechanisms where its applicable.
And for example its far better to return an empty dataset via an
ajax-call than a 404 or a login-page. So we actually filter the
datasets on what the user is allowed to view and not disturb him with
ugly error-messages...

Have fun,

Arnold

0 Comments:

Post a Comment

Subscribe to Post Comments [Atom]

<< Home


Real Estate