3 ms·
I 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
by buss 15y ago
I 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.