Git Product home page Git Product logo

Comments (11)

benkonrath avatar benkonrath commented on July 24, 2024

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:

https://github.com/dustinfarris/ember-django-adapter/blob/version-1.0/README.md#path-customization

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.

from ember-django-adapter.

dustinfarris avatar dustinfarris commented on July 24, 2024

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?

from ember-django-adapter.

benkonrath avatar benkonrath commented on July 24, 2024

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.

from ember-django-adapter.

g-cassie avatar g-cassie commented on July 24, 2024

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.

from ember-django-adapter.

dustinfarris avatar dustinfarris commented on July 24, 2024

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

from ember-django-adapter.

dustinfarris avatar dustinfarris commented on July 24, 2024

Resolved in #28

from ember-django-adapter.

g-cassie avatar g-cassie commented on July 24, 2024

I haven't looked at the code for your rewrite in detail but I remember Toran's adapter required urls for nested objects like /dealerships/1/cars/ and I was using @detail_view to implement these. I can't remember how multi-word models were treated. In any event if you want to support this kind of route structure than you should consider the following viewset.

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

from ember-django-adapter.

dustinfarris avatar dustinfarris commented on July 24, 2024

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.

from ember-django-adapter.

g-cassie avatar g-cassie commented on July 24, 2024

You may be thinking of the coalesceFindRequests option that was introduced in beta.9. However DRF does not natively support the requests ED generates with this option enabled so I think there is still work to be done on the adapter side.

from ember-django-adapter.

dustinfarris avatar dustinfarris commented on July 24, 2024

Gotcha. Would you mind opening an issue for it?

from ember-django-adapter.

g-cassie avatar g-cassie commented on July 24, 2024

Done: #32

from ember-django-adapter.

Related Issues (20)

Recommend Projects

  • React photo React

    A declarative, efficient, and flexible JavaScript library for building user interfaces.

  • Vue.js photo Vue.js

    🖖 Vue.js is a progressive, incrementally-adoptable JavaScript framework for building UI on the web.

  • Typescript photo Typescript

    TypeScript is a superset of JavaScript that compiles to clean JavaScript output.

  • TensorFlow photo TensorFlow

    An Open Source Machine Learning Framework for Everyone

  • Django photo Django

    The Web framework for perfectionists with deadlines.

  • D3 photo D3

    Bring data to life with SVG, Canvas and HTML. 📊📈🎉

Recommend Topics

  • javascript

    JavaScript (JS) is a lightweight interpreted programming language with first-class functions.

  • web

    Some thing interesting about web. New door for the world.

  • server

    A server is a program made to process requests and deliver data to clients.

  • Machine learning

    Machine learning is a way of modeling and interpreting data that allows a piece of software to respond intelligently.

  • Game

    Some thing interesting about game, make everyone happy.

Recommend Org

  • Facebook photo Facebook

    We are working to build community through open source technology. NB: members must have two-factor auth.

  • Microsoft photo Microsoft

    Open source projects and samples from Microsoft.

  • Google photo Google

    Google ❤️ Open Source for everyone.

  • D3 photo D3

    Data-Driven Documents codes.