On Wed, Sep 12, 2012 at 11:58 AM, Cal Leeming [Simplicity Media Ltd]looks nice. i like that it respects the idea that views in Django are
<cal.l...@simplicitymedialtd.co.uk> wrote:
> So, here is a really minimalistic way of having class based views, without
> the fuss.
>
> http://djangosnippets.org/snippets/2814/
just callables that take a reques (plus optional extra params) and
return a response. to get inheritance, just make callable objects and
spread functionality as desired.
the generic view functions are good for prototyping, but soon you have
to replace with your own, which is not difficult. the problem with
generic CBV is that they try to factorize every feature so thinly that
the inheritance becomes an unholy mess. any simplification would
either reduce functionality, or make some features harder to replace,
so there doesn't seem to be a way out... apart from not using them.
--
Javier
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To post to this group, send email to django...@googlegroups.com.
To unsubscribe from this group, send email to django-users...@googlegroups.com.
For more options, visit this group at http://groups.google.com/group/django-users?hl=en.
Op 12 sep. 2012 18:58 schreef "Cal Leeming [Simplicity Media Ltd]" <cal.l...@simplicitymedialtd.co.uk> het volgende:
>
> Hi all,
>
> There is a lot of debate on whether there is a real future for the Django CBVs (class based views).
..snip..
>
> Any thoughts?
>
I understand what you're getting at and agree in principle, but you're not exactly feature compatible. ;-)
> The method specified in the Request-Line is not allowed for the resource identified by the Request-URI. The response MUST include an Allow header containing a list of valid methods for the requested resource.
(From http://www.w3.org/Protocols/rfc2616/rfc2616-sec10.html).
--
You received this message because you are subscribed to the Google Groups "Django users" group.
To view this discussion on the web visit https://groups.google.com/d/msg/django-users/-/8vKvmPp9uTgJ.
On Thu, Sep 13, 2012 at 12:58 AM, Cal Leeming [Simplicity Media Ltd]Sigh.
<cal.l...@simplicitymedialtd.co.uk> wrote:
> Hi all,
>
> There is a lot of debate on whether there is a real future for the Django
> CBVs (class based views).
No - there isn't *any* debate about the future of CBVs. There *are* a
lot of people who apparently don't like them who keep making a lot of
noise. Every single time I've spoken with one of those people at
length, the problem has reduced to either:
1) I don't like classes/OO. There's no winning these people over.
2) CBV's aren't documented well. You won't get any argument from me
on (2). I'll take the hit for that -- the initial documentation for
CBVs was my doing, and it has lots of room for improvement.
I'm not aware of anyone in the core that has advocated removing
class-based views from Django.
What you've described -- a single entry point class-based view base
> Personally, I find them tedious, and just wanted a
> way to keep my views clean.
>
> So, here is a really minimalistic way of having class based views, without
> the fuss.
>
> http://djangosnippets.org/snippets/2814/
>
> This is a fork from:
>
> http://stackoverflow.com/questions/742/class-views-in-django
> http://djangosnippets.org/snippets/2041/
>
> My thanks to eallik for his initial post on stackoverflow for this.
>
> Personally I think Django's CBVs should offer a really minimalistic base
> like this, as well as the existing CBV stuff already in the core - so as to
> not force people into needing to learn an entirely new way of doing things,
> but at the same time allowing them to reap some of the benefits of using
> callable classes as views.
>
> Any thoughts?
class -- *does* exist. It's called django.views.generic.View. Override
the "dispatch" method, or write a "get/post/put/etc" method, and
you've got a class-based view.
I also think you should read the discussions that led to the current
form of Class-based views. The pattern you've proposed from Stack
Overflow was one of many suggestions that were made, and were rejected
because of inherent problems with the approach. The discussions are
summarised in the wiki:
https://code.djangoproject.com/wiki/ClassBasedViews
Yours,
Russ Magee %-)
--
You received this message because you are subscribed to the Google Groups "Django users" group.
Yours,
Russ Magee %-)