On Tuesday, June 5, 2012 at 10:35 AM, Carl Meyer wrote: > > > On 06/05/2012 08:12 AM, Donald Stufft wrote: > > In order to do this with FBV's i'd either need to modify the existing > > FBV to accept > > a parameter that says if it should filter by logged in user or not or > > copy/paste > > the code into a new FBV. > > > > > Not true, you can also have a function view that returns a > TemplateResponse, and do the same types of tweaks using reusable decorators. > >
Maybe in that exact case. You can take the example further and have the same or another Mixin also handling setting the user field of model instance (which on a tangent, is one of the places Generic CBV's can improve imo). So now you can Mixin automatically setting the ``user`` field of a Model to the currently logged in user. You could also be calling an external API, and want to pass additional data to that API in this instance of the view, TemplateResponse won't help you and the original options stand here where you either copy/paste the view, or modify the existing view. It's pretty much a fact that module level functions in Python are completely unable to deal with any modification to internal logic without building up a list of kwargs/flags that they accept. Even if you are forward thinking and break your FBV's into multiple sub functions that the actual view calls, you cannot modify how it calls those functions, or swap out which functions it calls without getting into hacky monkey patching or copy and pasting things. > > Carl > > -- > You received this message because you are subscribed to the Google Groups > "Django developers" group. > To post to this group, send email to django-developers@googlegroups.com > (mailto:django-developers@googlegroups.com). > To unsubscribe from this group, send email to > django-developers+unsubscr...@googlegroups.com > (mailto:django-developers+unsubscr...@googlegroups.com). > For more options, visit this group at > http://groups.google.com/group/django-developers?hl=en. > > -- You received this message because you are subscribed to the Google Groups "Django developers" group. To post to this group, send email to django-developers@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.