4 ms·
I've never understood why people like this framework so much. It's not that flexible. If you want to customize your API in specific ways ( ordering, nested reso
by junkmob 12y ago
I've never understood why people like this framework so much. It's not that flexible. If you want to customize your API in specific ways ( ordering, nested resources, validation ), then you will undoubtedly just write your own CBV(s).
After writing your own CBV(s) for awhile, you will either love that solution or hate it and look for something more flexible and out-of-the-box.
For many of the things that Django REST framework version 3 is attempting to solve there is already an awesome alternative to it and TastyPie called Conduit. I highly recommend people give it a shot, since it's pretty modular. It also presents a different alternative to Function and Class-Based views:
http://django-conduit.readthedocs.org/en/latest/ http://django-conduit.readthedocs.org/en/latest/
- Buetol 12y agoI also recommend restless(from the author of Tastypie): https://github.com/toastdriven/restless https://github.com/toastdriven/restless Really dead-simple to use and just plain fun.
- scrollaway 12y agoLooks interesting, might port one of my tastypie projects to it. However I'm very concerned about the author's inactivity. Tastypie has gone unmaintained several times for a long time. It looks like restless is headed that way as well. Concerning.
- findjashua 12y agoFlask-Restless has quickly become my favorite REST framework: http://flask-restless.readthedocs.org/en/latest/ http://flask-restless.readthedocs.org/en/latest/
- Spiritus 12y agoNot really applicable to Django, is it?
- parham 12y agoSame could be said about Django and APIs!
- andybak 12y agoBeen writing a Django-based API-heavy app and it still feels very Django. DRF fits the ORM like a glove and there's a Django way of doing things that runs throughout. Models ≈ ModelForms ≈ ModelSerializers ≈ ViewSets ≈ ModelAdmin. Certainly never feels like I'm fighting the framework(s).
- kyllo 12y agoGood point, but my impression of this tool is that it's more intended for quickly tacking an external API onto an existing Django app, and not so much for building an internal API for a client-side MVC app (Angular/Ember/Backbone etc). It can certainly be used for that too, but Django is kind of overkill for that use case, and a lighter-weight framework like Flask with a REST plugin like Restless and (optionally) an ORM plugin like SQLAlchemy is probably sufficient.
- parham 12y agoMy thought too but if your data is complex you should consider building an API first using an ORM more powerful than Django's (e.g. SQLAlchemy) then use Django to handle users and then allow your users to access the API directly via signed requests or something... that way you get good performance without network/Django ORM overhead.
- lumpypua 12y agoI prefer SQLAlchemy, but it definitely has just as much overhead as django's ORM. This is just a microbenchmark, but notice how when frameworks are making raw DB queries they stomp the ones using ORM: http://www.techempower.com/benchmarks/#section=data-r9&hw=i7&test=query&l=1kw http://www.techempower.com/benchmarks/#section=data-r9&hw=i7... Looking at only python frameworks using ORM, Flask with SQLA hits 85% of the requests/sec of Django using pypy, and only 73% on stock python. Django has decently lower latency as well (450ms django, 550ms flask pypy, 600ms flask stock python): http://www.techempower.com/benchmarks/#section=data-r9&hw=i7&test=query&l=1kw&o=1 http://www.techempower.com/benchmarks/#section=data-r9&hw=i7... Really, if performance matters at all and you want an ORM use Java. The fastest python solution using an ORM is a tenth as fast as the Java solutions, with literally 10x the latency. :P Flask making raw db queries gets within 2x of this, as does bottle. http://www.techempower.com/benchmarks/#section=data-r9&hw=i7&test=query&o=3 http://www.techempower.com/benchmarks/#section=data-r9&hw=i7...
- deleted 12y ago[deleted]
- mpdehaan2 12y agoDjango Rest Framework for us - http://ansible.com http://ansible.com - was easier to customize and also easier to graft in custom auth. One of the major tastiepie problems we had - that maybe everybody doesn't have, was how to be able to make collections hang off REST resources. The greatest feature by far is the API browser, which in DJRF 2 (I have no sense of what's in the 3rd version) is pretty amazing and a great way for people to learn about an API. Less automagic made it much more flexible for us, while the API browser is just amazing in a end-user demo. It's my favorite feature, though I also like the serializer system. http://www.django-rest-framework.org/topics/browsable-api http://www.django-rest-framework.org/topics/browsable-api
- hyperliner 12y agoI would say here that the balance is between having something fit-for-purpose vs. something that is more flexible. Not familiar with Conduit though so can't compare.