python - How to create n-collection deep url in Django Rest-framework -
we creating service user can force info through api create resources , collections. want offer user 1 collection can add together single info resources, or collections subcollections , resources. quite close analogy file-system files , folders.
this kind of scheme create urls like:
www.example.com/api/mycollection/books/thebook www.example.com/api/mycollection/thing www.example.com/api/mycollection/something/theimportant/myvisa as can see, between final info resource , "mycollection" there can amount of collections depending on how collection owner has pushed info api earlier. each collection should callable find out content.
with django rest framework know can define urls this:
(r'^api/(?p<rootcollection>\w+)/(?p<subcollection>\w+)/$', views.listentries.as_view()), and can take parameters api-view used in database queries or whatever. question how can generalize pattern there can amount of these parameters?
my friend suggested create apiview responds urls begin "^api/" , handle rest of url in apiview extracting rest of url parts list of words. based on these words can create query db , build json-response based on request. thought create sense or there improve solutions in drfw?
python django rest django-rest-framework
No comments:
Post a Comment