-
-
Notifications
You must be signed in to change notification settings - Fork 7k
"Rails-like" relationship urls #738
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
Conversation
We have gone for the nested resources option in our API. We created all of the URLs by hand. What exactly are you suggesting? An automated URL generator that can map back to specific views? That would be pretty sweet. |
+1 for this, I think it's a great idea and is intuitive for most master/detail resources. This would be a big win if it happened somewhat automatically. |
This would be great! Currently, we are doing this in a bit of an unholy way for minor resources such as Likes and Subscribes on major resources. |
I see that I'm not the only one wishing for this feature :) |
wrt. automatic routing, that's the big upcoming plan for 2.3 There's a bit of draft documentation here (tho I don't think it does a great job of explaining things, and I've been refining my ideas a little since I first wrote it.) In summary we'll have Eg. The final tutorial set should end up looking something like this... views.py
urls.py
|
Great! A If I understand correctly the tutorial 6, this was written for the django-rest-framework 1.x ? I'm asking because I'm kind of new :) Do you want me to rename this pull request to something like Automatic Routing for 2.3 ? |
@dulaccc - There's two separate things here right, the automatic routing, and the "sub-relationships". The "sub-relationships" we should keep against this ticket. The ViewSet & Router stuff I've opened a preliminary pull request, just to get things rolling... |
Thanks for the precision @tomchristie. I was indeed mixing the two things. Without any link, I'm not very confident with the choice I made on making I know your attention to detail, and I've got that too usually ^^, that's why I'm asking for guidance if you already thought this through. |
Closing this issue now that 2.3 is almost pending release. |
Looks like you saw django-viewsets before doing this ;) |
Hi @BertrandBordage. Considered adding to your thread on django-dev mentioning this, yeah. :) |
OK, great :) <off_topic> |
@BertrandBordage - The separation of concerns between router and viewset felt right, and I really like how viewset is now just a small incremental change on top of regular views. And glad you're enjoying the framework. :) |
I finally had the time to work again with |
The idea is to take the best from RoR ! ;)
I think their approach of relationship browsing is very intuitive and great to use.
With the following example taken from the doc
we could access the tracks of an album with the url
/api/album/1/tracks
.I'm working on an implementation, but all the ideas, thoughts and opinions are welcome.
First thing, do you think it's a good idea ?