4 ms·
There’s no need for a framework since you can do: values = User.objects.all().values('id', 'username') results = json.dumps(values) …or use the builtin JSON
by lcnmrn 10y ago
There’s no need for a framework since you can do:
values = User.objects.all().values('id', 'username')
results = json.dumps(values)
…or use the builtin JSON serializer. You can also use Paginator to paginate the results.
- 5h 10y agoWhy use a website - just have your users call you and ask you to do things.
- morninj 10y agoThat's a small chunk of the functionality most APIs need. Why write all of your API views from scratch when there's an excellent framework that handles it for you?
- Daishiman 10y agoAssuming you don't want to transform data, provide your own custom serializers, provide pluggable auth modules and authentication methods, CRUD viewsets, accepting and receiving multiple response types, then yeah.
- mastazi 10y agoYour comment is being downvoted because DRF clearly does a whole lot more than just serialising the response dictionary or adding pagination, you should really have a look at the documentation. However, I still think that Django should have something like the "JSONResponse mixin example"[1] built-in by default; sometimes you are building a product which is not an API but you still need the occasional RESTful endpoint and, in those cases, something like DRF would be overkill. [1] https://docs.djangoproject.com/en/1.10/topics/class-based-views/mixins/#jsonresponsemixin-example https://docs.djangoproject.com/en/1.10/topics/class-based-vi...
- ralmidani 10y agoYou could always import DRF's serializers and parsers/generators without committing to the entire framework. Django does plan on bringing DRF's content negotiation into the main framework: https://www.djangoproject.com/weblog/2015/dec/11/django-awarded-moss-grant/ https://www.djangoproject.com/weblog/2015/dec/11/django-awar...
- mastazi 10y agoThanks, that would be a reasonably light-weight alternative.