3 ms·
When you say objects I assume you mean model objects? In that case yes. I haven't used Piston or Tastypie in awhile, but I know that you can easily write views
by slewis 15y ago
When you say objects I assume you mean model objects? In that case yes. I haven't used Piston or Tastypie in awhile, but I know that you can easily write views in django-rest-framework that aren't tied to models.
This is a bullet from the django-rest-framework page I linked above: "Modular architecture - MixIn classes can be used without requiring the Resource or ModelResource classes."
Here's one of the examples from django-rest-framework that is not tied to models: http://django-rest-framework.readthedocs.org/en/latest/examples/pygments.html http://django-rest-framework.readthedocs.org/en/latest/examp...
And also, from the Tastypie docs: http://django-tastypie.readthedocs.org/en/latest/resources.html#why-resource-vs-modelresource http://django-tastypie.readthedocs.org/en/latest/resources.h...
- buss 15y agoI read through both of those links and I think I wasn't clear with my initial question. I want to expose arbitrary view methods to GET calls, not linked to any model, and not have to write a new class for every view I want to expose. Basically I want views to return the correct filetype (json, html, xml, etc) when requested. This is basically making django a little more rails-like. I'm leaning towards django-dynamicresponse currently. I really like how the three you mentioned tie into Django's forms though, and that's quite a feature to give up.
- rglullis 15y agoYes, you can get djangorestframework to be used without being tied to any model, or even without tying it to a resource. In its current incarnation, djangorestframework just follows the principle from generic class-based views. You just define a view that inherits from djangorestframework.views.View, and implement the action methods (get/post/put/delete) that you want. These methods must return a dictionary, and the framework handles the part of dispatch and render the view in the proper format.
- buss 15y agoThat was a really helpful answer, thanks! I'll be taking another look at djangorestframework; hopefully I didn't miss anything else.