Closed aop closed 9 years ago
Agree that that docs are misleading as to the current behavior there, but not sure if that's a docs fix, or if we need to change the default behavior.
Assuming this is a duplicate of #1319, but not clear to me that it really was properly addressed, or if #1333 (available in the upcoming 2.4.0) only addressed a subset of the problem.
DjangoCon sprint guidance - review current behaviour, summarise what you would expect desired behaviour to be.
My expectations for the behavior would be the following:
# should work
example.com/test.json
# should NOT work
example.com/test/.json
I have mixed thoughts on the following: example.com/test.json/
I kind of like the idea of requiring the specification of a data format to be the very end of an address. This would mean not allowing a trailing slash. However, others may have use cases that would disagree with this approach.
Our group specifies content type via the HTTP Accept Header; however, I agree with the support for specifying the data format via an address.
Lastly, I think the documentation should at least be updated to include samples as to which addresses are expected to work based on the usage of the format_suffix_patterns functionality.
Seems reasonable.
I've always found that comments/.json
is just plain weird and confusing.
Expected for me is:
http://localhost:8000/comments.json
# perhaps this too
http://localhost:8000/comments.json/
http://localhost:8000/comments/?format=json
If behavior doesn't change for now, updating docs might be a good idea.
I agree with this. This is coming from someone completely new to the framework and going through the tutorial, so take that as you wish. However, the tutorial even gives the example that using format_suffix_patterns
should make it so the API will be able to handle URLs such as http://example.com/api/items/4.json
Edit: The example HTTP requests later on the same page show the proper request with the trailing forward slash. So maybe this should just be a doc change higher up. However, I would still agree that without a forward slash makes more sense.
According to http://www.django-rest-framework.org/api-guide/format-suffixes the suffices should be used directly after the resource name like http://example.com/api/users.json but format_suffix_patterns applies them after the trailing slash if one is used in the urlpatterns it gets (like the DefaultRouter does)
This results in 404 when trying to use them in the tutorial app for example: http://restframework.herokuapp.com/users.json