Live data from Hacker News

Django REST framework 2.3 released: ViewSets and Routers

django-rest-framework.org

1–10 of 37 posts

Re: Django REST framework 2.3 released: ViewSets and Routers

#3

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?

Re: Django REST framework 2.3 released: ViewSets and Routers

#6
post #5

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

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.

Re: Django REST framework 2.3 released: ViewSets and Routers

#7
post #6
post #5

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

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.

Personally I find it much more powerful and organised than TastyPie, and you can use it for much more basic stuff. You don't actually have to do REST at all.

Regarding the boilerplate - IIRC the tutorial starts you off with lots of boilerplate then shows you how to refactor it so it is not needed.

Re: Django REST framework 2.3 released: ViewSets and Routers

#9
post #6
post #5

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

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/django-rest-framework

I get the impression that what TastyPie does really well is convention-over-configuration - making a bunch of really sensible design decisions on your behalf. What (I hope) REST framework does really well is staying close to Django's conventions, and being easy to customize all the way through, plus of course the browseable API. Either way, there's certainly plenty of folks happy with both frameworks.

Re: Django REST framework 2.3 released: ViewSets and Routers

#10
post #5

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

Django REST framework inherits its Views from Django's Class-Based Views. If your app is using CBVs elsewhere, it is one less interface to have to get familiar with. When I need to do something a little advanced the familiar methods get(), post(), dispatch(), get_queryset(), etc are present. Also, most Mixins for Django's CBVs work fine with Django REST framework's Views. Django REST framework separates its logic into two main classes Serializers and Views, compare to Django TastyPie which combines these concepts into a class called a Resource. A Resource also combines what is a ListAPIView and RetrieveAPIView in Django Rest framework, but having them seperate can let you do things like return different model fields for the ListAPIView verus the RetrieveAPIView. Django REST framework's standout feature is the browsable API, which lets explore the API from your browser.

TastyPie is more "complete" than Django REST framework. It has URL routing, which makes setting up an API namespace in your URLs super simple. It has queryset filtering from the URL (e.g. /articles/?author=1). Django REST framework relies on another third-party app to do this. It also has caching built-in. I find it's internal interface a little bit more confusing the Django REST framework's, but that could be that I am just more familiar with Django CBVs.

Post reply on HN