Hacker Newsnew | past | comments | ask | show | jobs | submitlogin
RFC: Object-based Views in Django (zacharyvoase.com)
8 points by zacharyvoase on Jan 22, 2013 | hide | past | favorite | 3 comments


Zachary, today I was thinking along the same lines and I really really like your proposal!

How do you propose object-based views to expand beyond the generic cases in order to handle for example multiple forms, or hiding a field from a form and then adding that (for example request.user) after form validation, before save , or add some additional logic to a detail view?

In my opinion, IDS['slug'] would be neater than ids.SLUG

And now for something completely different: An other idea of mine which keeps going around in my head is having addable forms, so you can do total_form = profile_form + company_form and easily validate etc. What do you think?


Regarding handling multiple forms: I don't actually propose handling that. Python is good for writing code, which normally ends up being pretty expressive. The more we try to encapsulate that behavior in frameworks, the worse that code looks, and the more difficult to debug it becomes.

I do believe that having a collection of 'form combinators' would be useful.


Ruby on Rails had a lovely scaffolding system that everyone told me not to use.

Python tells me to be explicit instead of implicit.

It's also nice to not have much magic in our frameworks.

CBVs leave a lot to be desired but FBVs were terrible when you did really want to reuse code. I can never decide with CBVs whether I like the declarative approach but I can only see this resource magic being overridden as quickly as you can put it in at least with CBVs with every new mixin or subclass I feel I'm truly extending on something (albeit with additional MRO complexity but then maybe you have bigger problems if you're finding those kinds of issues).




Guidelines | FAQ | Lists | API | Security | Legal | Apply to YC | Contact

Search: