In the test example http://django-rest-interface.googlecode.com/svn/trunk/django_restapi_tests/examples/custom_urls.py on line 19 to they parse the request.path to get the poll_id. This looks very fragile to me. If the url changes then this line breaks. I have attempted to pass in the poll_id but this did not work. So my question is how do I use the poll_id (or any other value) gathered from the url?
In the test example http://django-rest-interface.googlecode.com/svn/trunk/django_restapi_tests/examples/custom_urls.py on line 19 to they parse the request.path to
Share
Views are only called when the associated url is matched. By crafting the url regex properly, you can guarantee that any request passed to your view will have the
poll_idat the correct position in the request path. This is what the example does:The
json_choice_resourceview is an instance ofdjango_restapi.model_resource.Collectionand thus theread()method ofCollectionwill only ever act on requests with paths of the expected format.