What is the advantage of Class-Based views?

后端 未结 5 381
-上瘾入骨i
-上瘾入骨i 2020-12-12 11:19

I read today that Django 1.3 alpha is shipping, and the most touted new feature is the introduction of class-based views.
I\'ve read the relevant documentation, but I fi

5条回答
  •  眼角桃花
    2020-12-12 12:00

    This is the first I'm hearing of this -- and I like it.

    The advantage I see here, honestly, is that it makes views more consistent with Django overall. Models are classes and I've always felt that views should be too. I know not everything is but views and models are the two heavily used types.

    As for the technical advantage? Well, in Python everything is a class (or object?) -- so is there really a difference? Isn't it 99% syntactical sugar in the first place?

提交回复
热议问题