Live data from Hacker News

Django REST framework 2.3 released: ViewSets and Routers

django-rest-framework.org

11–20 of 37 posts

Re: Django REST framework 2.3 released: ViewSets and Routers

#11
post #5

Anyone care to weigh in about using this vs., say, TastyPie?

We looked at and started playing with TastyPie over at Pathwright, but ultimately found that it was very difficult to customize to our needs (mostly with respect to custom API resources, custom filtering, and very fine-grained permissions based on a number of factors). The documentation isn't organized very well, and at the time (a few months ago), it appeared that development had stalled.

After getting pretty frustrated with TastyPie, we gave rest-framework a try as a last resort before we'd consider doing our own thing. So far, we have found rest-framework to be a whole lot more readable, much more actively maintained, much easier to get help for, and much easier to customize permissions and queryset filtering for.

To us, this ended up being a no-brainer. rest-framework has less magic, it is less complicated, it was easier for us to customize, and the organization of the documentation makes more sense.

But, as with most things, YMMV. We really like rest-framework, but don't take my word for it.

Re: Django REST framework 2.3 released: ViewSets and Routers

#12
post #6

Earlier quoted context omitted.

Last I tried this (2.1?) it took a hell of a lot more boilerplate than TastyPie, and I had a few problems that necessitated changing the source a bit. But maybe I was using it wrong (didn't spend a huge amount of time with it). The auto generated web interface is nice though.

Author here... The boilerplate comment is definitely valid, and is pretty much what this release was intended to address. We've now introduced ViewSets (an extension of class based views that is similar to Rail's controllers) and Routers, which make it super quick and easy to get your API up and running. The updated README should give you a good idea how simple the APIs can be now: https://github.com/tomchristie/djan…

I'll take boilerplate over magic any day. The thing that irked me the most about TastyPie was the magic and lack of obvious understanding of what was happening under the hood (without source diving).

The Zen of Python has something to say about this.

Re: Django REST framework 2.3 released: ViewSets and Routers

#13
Using 2.1 of this framework and an HBase database, we've been able to reduce load times for data in one of our applications from about 30 seconds down to less than 1. Arguably, this had a lot to do with HBase, but rest-framework is actually really nice and seems to work well in regards to performance.

Re: Django REST framework 2.3 released: ViewSets and Routers

#14
post #5

Anyone care to weigh in about using this vs., say, TastyPie?

The Rest Framework is a lot more flexible and just don't get into your way when you need your API to do anything else than exposing CRUD operations.

The whole design of DRF makes a lot more sense for my use cases.

TastyPie provides you with Resources that do everything from accepting and dispatching methods, querying db, authentication and authorization to parsing an serializing data. If you want to modify one puzzle you have to redefine the resource.

In DRF the separation between request processing, data serialization/deserialization, rendering and other elements is more clear.

API endpoints are just views that are based on Django class-based views so you should already know how to customize them, do queries and use mixins. Serializers perform data validation (similar to forms, but can handle collections and relations) and conversion between objects and native Python datatypes. They can also be reused in multiple views or for nested relations. Other components are pluggable so you can specify parsers, renderers and auth backends for the whole API or for just a particular view.

The Rest Framework just feels right and works well when you need to do any sort of customization. On top of that you get a very detailed documentation and a browsable API.

TastyPie served me well for a long time and I'm very thankful to the developers, but I find DRF to better suit my needs.

Re: Django REST framework 2.3 released: ViewSets and Routers

#15
post #5

Anyone care to weigh in about using this vs., say, TastyPie?

I tried all rest frameworks I could find for both Django and Flask - for me DRF is the cleanest.

The standard html interface for it (and content type handling) are definitely the best of all of them. You can get a very complete api up and running with not much effort.

The documentation is really nice and clear and if you get stuck just take a look at the code - it's very easy to follow. You should look at it anyway, it's nice code to read through.

My only complaint is that it's not built for Flask :)

Re: Django REST framework 2.3 released: ViewSets and Routers

#16

What's with the nav box completely blocking the document? http://cl.ly/OnPN Running Chrome 28.0.1496.0 dev

Note sure. I seem to be able to replicate that if the browser window is exactly 727 pixels wide, but otherwise everything displays just fine for me on Chrome 26.0.1410.65. Will look into it later. Edit : Are you seeing this for all browser widths, or just specific ranges?

I took a quick video of it on my machine: OSX 10.8.3, Chrome Canary Version 28.0.1499.0 canary. It doesn't happen on any other browser on my machine (Vanilla Chrome, Firefox, FirefoxNightly)

http://screencast.com/t/2DOssUNcJrGt

Re: Django REST framework 2.3 released: ViewSets and Routers

#17
post #16

Earlier quoted context omitted.

Note sure. I seem to be able to replicate that if the browser window is exactly 727 pixels wide, but otherwise everything displays just fine for me on Chrome 26.0.1410.65. Will look into it later. Edit : Are you seeing this for all browser widths, or just specific ranges?

I took a quick video of it on my machine: OSX 10.8.3, Chrome Canary Version 28.0.1499.0 canary. It doesn't happen on any other browser on my machine (Vanilla Chrome, Firefox, FirefoxNightly) http://screencast.com/t/2DOssUNcJrGt

Thanks, appreciated.

Re: Django REST framework 2.3 released: ViewSets and Routers

#18
post #16

Earlier quoted context omitted.

I took a quick video of it on my machine: OSX 10.8.3, Chrome Canary Version 28.0.1499.0 canary. It doesn't happen on any other browser on my machine (Vanilla Chrome, Firefox, FirefoxNightly) http://screencast.com/t/2DOssUNcJrGt

Thanks, appreciated.

While you're in there, there's a conflict in the content of the tutorial, at the end of the URLs section: http://django-rest-framework.org/tutorial/quickstart.html

Re: Django REST framework 2.3 released: ViewSets and Routers

#19
post #6

Earlier quoted context omitted.

Last I tried this (2.1?) it took a hell of a lot more boilerplate than TastyPie, and I had a few problems that necessitated changing the source a bit. But maybe I was using it wrong (didn't spend a huge amount of time with it). The auto generated web interface is nice though.

Author here... The boilerplate comment is definitely valid, and is pretty much what this release was intended to address. We've now introduced ViewSets (an extension of class based views that is similar to Rail's controllers) and Routers, which make it super quick and easy to get your API up and running. The updated README should give you a good idea how simple the APIs can be now: https://github.com/tomchristie/djan…

The boilerplate was exactly why I went with Tasty-Pie recently, but seeing some of the updates, I might have to revisit that decision. Your documentation is great, btw.

Side note -- the updated urls.py example in the README.md references "views.UserViewSet" but in the context of the example should just be "UserViewSet"... I think. I sent a pull request - ignore if I had it all wrong.

Re: Django REST framework 2.3 released: ViewSets and Routers

#20

Earlier quoted context omitted.

Thanks, appreciated.

While you're in there, there's a conflict in the content of the tutorial, at the end of the URLs section: http://django-rest-framework.org/tutorial/quickstart.html

Ooops. Fixed now - thank you!
Post reply on HN