Working towards a simpler GCBV implementation?

678 views
Skip to first unread message

Tom Christie

unread,
Oct 3, 2013, 5:09:58 AM10/3/13
to django-d...@googlegroups.com
Hi folks,

I recently released an alternative implementation of Django's existing class based views.  The intention was to mirror the *exact* same set of functionality that we currently provide, but simplify the implementation and API.  It's nothing cleverer or grander than a clean re-write, but the end result is *significantly* less complex.  The class hierarchy is trivial, the API is much smaller, and the flow control is much more obvious.

I won't go into any more here, as there's plenty of detail in the documentation:


There's also useful context in the related blog post, here:


The difficult thing here really is that there's no obvious approach to introducing something like this in a backwards compatible way.

It might be that we could take an incremental approach using the standard deprecation process, but given the nature of the GCBVs it'd likely be pretty awkward.
There might be some bits of deprecation process we simply wouldn't be able to deal with in any sensible way, and we'd certainly end up with a seriously gnarly implementation during the deprecation period.

I'd be interested in getting some opinions from folks on the following:

* If a simpler GCBV implementation along the lines of django-vanilla-views is something we think we should working towards.
* What approaches we might be able to take to dealing with backwards compatibility if we did want to do so.

Thanks for your time.

  Tom

Yo-Yo Ma

unread,
Oct 4, 2013, 12:22:42 AM10/4/13
to django-d...@googlegroups.com
I'm excited about Django Vanilla Views. I think the GCBV implementation in Django is pretty good (I use GCBV got everything - leads to better extensibility), but a simpler version of the same functionality would be great. I'm NEVER certain of whether I'm using the right mixins and base class combos, or if I have them in the right inheritance order, or which share the same function, etc.

Tino de Bruijn

unread,
Oct 5, 2013, 7:27:55 AM10/5/13
to django-d...@googlegroups.com
On Thu, Oct 3, 2013 at 11:09 AM, Tom Christie <christ...@gmail.com> wrote:
* If a simpler GCBV implementation along the lines of django-vanilla-views is something we think we should working towards.

Hells yes, +1. I love CBV, but when it gets a little more complex, I get dazzled.
 
* What approaches we might be able to take to dealing with backwards compatibility if we did want to do so.

Hmm,  from django.new_views import ..., like was done with new_forms?


Albert O'Connor

unread,
Oct 5, 2013, 8:38:37 AM10/5/13
to django-d...@googlegroups.com
+1 to anything which makes CBV easier to use and simpler to understand.

From looking at what have done you have been able to address my biggest concern, the depth of the hierarchy. I find using flat "CBV" like the syndication framework a lot easier then the current GCBV implementation.

Thanks,
Albert O'Connor


--
You received this message because you are subscribed to the Google Groups "Django developers" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.
Visit this group at http://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/CANQFsQCg7zVkjvRM4M6MdvhtmkBMqyp-FhAr12yjFF57nJY0Yw%40mail.gmail.com.

For more options, visit https://groups.google.com/groups/opt_out.



--

James Pic

unread,
Oct 5, 2013, 9:45:38 AM10/5/13
to django-d...@googlegroups.com
I should state that I have no education and that I have the feeling
that I understand GCBVs perfectly.

But django-vanilla-views are not as usable because you cannot reuse
isolated pieces of functionality like you can with mixins.

Maybe this is a documentation problem ?

Maybe the docs should explicitly recommend to read the source code ?

Maybe it should recommend some links for users to sharpen their
understanding of GCBVs ?

Hope this helps

James

--
http://yourlabs.org

Tom Christie

unread,
Oct 10, 2013, 5:25:38 AM10/10/13
to django-d...@googlegroups.com
> But django-vanilla-views are not as usable because you cannot reuse isolated pieces of functionality like you can with mixins.

The reusable components that it gives you are `GenericView` and `GenericModelView`.
Generally they're going to be the baseline that you'd want to work with anyways.
As one example of reusing these base components I've refactored Andrew Ingram's `django-extra-views` package using vanilla views. (*)
The end result is a set of generic views for dealing with formsets that came out something like 2/3 as much code as was previously required, and again, with a much simpler more obvious implementation throughout.

> from django.new_views import ..., like was done with new_forms?

Okay, so there's a precedent.
Really I'm still trying to sound out where the community stands on this.
If there was a pull request along these lines should I expect it to get rejected out of hand as too much of a radical change, or are folks sufficiently convinced that this is a good idea?

Thanks,

  Tom

(*): See https://github.com/tomchristie/django-extra-views - Not properly doc'ed or packaged yet, but considering doing so and releasing as a `django-vanilla-formsets` package.

Asif Saifuddin

unread,
Sep 15, 2016, 3:37:36 PM9/15/16
to Django developers (Contributions to Django itself)
Hi Tom,

I am basically +1 to see this change in the django core. The package is 3 years old and should be tested enough. If you/other core team members thinks that now is a good time to include it to core and deprecation of older API, then I will be willing to work and send PR for this.

Looking for others opinions.

Thanks,

Asif

Asif Saifuddin

unread,
Jan 3, 2017, 8:02:24 AM1/3/17
to Django developers (Contributions to Django itself)
Hi,

I have started work on https://github.com/django/django/pull/7783 for converting django built in generic views to django-vanilla-views.

I would like to hear what you think before I proceed for more.

Thanks,

Asif

Adam Johnson

unread,
Jan 3, 2017, 8:20:24 AM1/3/17
to django-d...@googlegroups.com
I think this is probably too disruptive a change for Django core, especially after so long with the current GCBV implementations - it would require all users to rewrite their CBV's. Possibly the documentation could recommend django-vanilla-views?

--
You received this message because you are subscribed to the Google Groups "Django developers (Contributions to Django itself)" group.
To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscribe@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.
Visit this group at https://groups.google.com/group/django-developers.
To view this discussion on the web visit https://groups.google.com/d/msgid/django-developers/5792872e-157c-4ba6-87c1-bf0f5a07d981%40googlegroups.com.
For more options, visit https://groups.google.com/d/optout.



--
Adam

Asif Saifuddin

unread,
Jan 4, 2017, 7:30:54 AM1/4/17
to Django developers (Contributions to Django itself)
Hi,

I will update the doc pointing vanilla views as simpler alternative implementation.

Thanks
To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.



--
Adam

Tim Graham

unread,
Jan 4, 2017, 8:08:54 AM1/4/17
to Django developers (Contributions to Django itself)
We typically shy away from endorsing third-party libraries in the Django docs. I don't think it makes much sense to stay something to the effect of "The built-in views are too complex so we recommend using other library instead."

Adam Johnson

unread,
Jan 4, 2017, 3:00:03 PM1/4/17
to django-d...@googlegroups.com
Fair enough, there are other community resources for this.

The PR adding a pointer in the docs to ccbv.co.uk in https://github.com/django/django/pull/7785 is a good idea that came from this thread though.

To unsubscribe from this group and stop receiving emails from it, send an email to django-developers+unsubscribe@googlegroups.com.
To post to this group, send email to django-developers@googlegroups.com.

For more options, visit https://groups.google.com/d/optout.



--
Adam

Alex Scott

unread,
Jan 6, 2017, 5:11:37 AM1/6/17
to Django developers (Contributions to Django itself)
If most everyone agrees that Tom's Vanilla Views are superior than what's currently in core, maybe the path forward is to integrate into 2.0?



--
Adam

Florian Apolloner

unread,
Jan 6, 2017, 7:26:04 AM1/6/17
to Django developers (Contributions to Django itself)
On Friday, January 6, 2017 at 11:11:37 AM UTC+1, Alex Scott wrote:
If most everyone agrees that Tom's Vanilla Views are superior than what's currently in core, maybe the path forward is to integrate into 2.0?

2.0 is not going to be as backwards incompatible as you might, it is mainly 2.0 because we drop py2.

Sayid Munawar

unread,
Jan 11, 2017, 7:04:57 AM1/11/17
to Django developers (Contributions to Django itself)
+1 to use vanilla-views in django 2.0

every time i write some view, i always open https://ccbv.co.uk/ in another tabs :D and trying to figure out where should i make my overrides 

James Bennett

unread,
Jan 11, 2017, 7:10:22 AM1/11/17
to django-d...@googlegroups.com
Please read Florian's message. 2.0 is not going to be "we bumped the major version, now we can pile in lots of breaking changes".

Asif Saif Uddin

unread,
Oct 14, 2021, 2:59:54 PM10/14/21
to Django developers (Contributions to Django itself)
IMHO, we can include vanilna views like simpler implementations for GCBV and may be ViewSets As well. extensively document the old iplementations to newer implementations, and not deprecating the current implementations that early. they way django regex_based url was converted to sipler path() based url routing, that could be a good path for this.

Best,
Asif

Asif Saif Uddin

unread,
Oct 14, 2021, 3:05:11 PM10/14/21
to Django developers (Contributions to Django itself)
all good new things were disruptive in django no matter what. urls and paths existed but the newer approach were recommended for new projects. the current GCBV are not so simple.

To unsubscribe from this group and stop receiving emails from it, send an email to django-develop...@googlegroups.com.
To post to this group, send email to django-d...@googlegroups.com.



--
Adam
Reply all
Reply to author
Forward
0 new messages