Hacker News new | ask | show | jobs
by OMBUG 4789 days ago
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.

2 comments

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.

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.

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.

I'd be curious to know what magic is in tastypie? It's some of the most straightforward python code I've ever read.
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.