-----BEGIN PGP SIGNED MESSAGE----- Hash: SHA1 Hi Russell,
On 10/10/2011 06:13 AM, Russell Keith-Magee wrote: > Getting "admin-like" functionality into the mainstream was one of the > prime motivations behind the introduction of class-based generic > views. Django's admin contains a number of neat features (like > fieldsets, views with inline formsets, filtering and searching) that > can be very easily implemented as a set of class-based mixins or > extensions. I've got code in private repositories that implement some > of these features; I'd like to find the time to clean them up as > generic utilities. FWIW, TemplateResponse was introduced in the same release as the CBVs, and it allows these same generic utilities (sorting, filtering, pagination) to be easily implemented as reusable decorators on top of TemplateResponse-using views. Having tried both approaches in different projects, I find the code using TemplateResponse and decorators more concise, readable and maintainable than the equivalent using CBV mixins; there are not nearly as many subtle ordering and what-calls-what-when issues, method names to memorize, and extraneous super() noise. If you do get the CBV versions cleaned-up and public, I'd be happy to put together the equivalent in decorator style for a head-to-head comparison :-) I also agree with tWoolie that as much of the functionality as possible should be implemented separate from anything that's tied to views, so it's more easily reusable for e.g. filtering two different lists in the same view. The decorators and/or mixins should be a relatively light glue layer between views and some kind of Sort/Filter objects (roughly analogous to the Paginator object). Carl -----BEGIN PGP SIGNATURE----- Version: GnuPG v1.4.10 (GNU/Linux) Comment: Using GnuPG with Mozilla - http://enigmail.mozdev.org/ iEYEARECAAYFAk6TGP0ACgkQ8W4rlRKtE2coFACffzpv6SZ621Qe0TARJlNYP0bX AdEAniAeOrZNHjxTtpxz04avwZ1vA/Nj =t1A5 -----END PGP SIGNATURE----- -- You received this message because you are subscribed to the Google Groups "Django developers" 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-developers?hl=en.
