-
Notifications
You must be signed in to change notification settings - Fork 49
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
pathForType/buildURL should dasherize CamelCase types #19
Comments
I initially used the dasherized version but @g-cassie pointed out that DRF defaults to the lower-cased pluralized model name without dashes. There's even a note about this in the README: Personally I'll always use the dasherized version because I think it's easier to read and it's more like django slugs but I'm also ok with overriding this to my preference. We should just pick one version and document it. I'm ok if it goes back to the dasherized version. |
I must have missed the discussion. I didn't realize DRF made a decision in that regard. My understanding is that the user makes this distinction when creating a router, e.g.: router = DefaultRouter()
router.register(r'furry-animals', viewsets.FurryAnimalViewSet) I realize that DRF does a lowercase dash-less version of the model name when creating internal references, e.g.: reverse('furryanimal-list') which is more or less in line with how Django handles ContentTypes; but this has nothing to do with the URL. Or am I missing something? |
Yeah, you're correct. I thought that the URL would be generated if you didn't provide it. I just read the DRF code and that's not correct. @g-cassie even figured out the initial mistake about confusing the URL and the internal reference in #11 but I still thought keeping the change in - I don't remember why, sorry. I agree with changing to the dasherized version. |
My other point was that @detail_view and @list_view default to underscorized urls which is why I thought it made sense to default to underscore on the adapter side. I think either way works but you should add docs for setting up @detail_view and @list_view to have dasherized urls. |
related conversation regarding detail_view/list_view URLs: encode/django-rest-framework#2010 it looks like @tomchristie is on board with at least making dashes an option for these endpoints, although it may not happen for a while. regardless, to my knowledge there is no native Ember functionality that makes use of custom endpoints like these (correct me if I'm wrong) so our dasherizing policy should stem from best/common practices seen in basic CRUD URLs |
Resolved in #28 |
I haven't looked at the code for your rewrite in detail but I remember Toran's adapter required urls for nested objects like class ZooViewSet(viewsets.ModelViewset):
@detail_view(methods=['get'])
def fuzzy_animals(self, request):
queryset = self.get_object().fuzzy_animals.all()
serializer = FuzzyAnimalSerializer(queryset, many=True)
return serializer.data |
Good point. We will need to investigate this further. I vaguely recall thinking that endpoints for nested relationships like this were no longer necessary, but I can't remember what the reasoning was, or if I was even correct. Anyway, we should probably open a new issue for this specific requirement. |
You may be thinking of the |
Gotcha. Would you mind opening an issue for it? |
Done: #32 |
To reproduce
DRFAdapter.pathForType('FurryAnimals');
Expected result
furry-animals
Actual result
furryanimals
The text was updated successfully, but these errors were encountered: