drf-extensions icon indicating copy to clipboard operation
drf-extensions copied to clipboard

Hyperlink fields that support nested serialization

Open thedrow opened this issue 10 years ago • 18 comments

drf-nested-routers provides (incomplete) nested versions of hyperlinked fields (https://github.com/alanjds/drf-nested-routers/blob/master/rest_framework_nested/relations.py). It be awesome to have those in drf-extensions.

thedrow avatar Jul 03 '14 13:07 thedrow

Yep, we need it. I don't have time for this feature right now, but it's next in the order. It would be great if you started and sent pull requests or suggested some thoughts how it should be implemented.

chibisov avatar Jul 04 '14 09:07 chibisov

I think this is a good idea as well. I spent an hour or so trying to get it to work, before looking at the code and seeing that it's not possible yet. For now, I'm using nested and un-nested urls, but hyperlinking to the un-nested one. It will be nice when this feature can be implemented.

DSpeckhals avatar Jul 24 '14 20:07 DSpeckhals

https://github.com/tomchristie/django-rest-framework/issues/1978 will certainly help or resolve this issue entirely.

thedrow avatar Oct 26 '14 12:10 thedrow

It appears that Tom has rejected the proposal from the issue above.

I have a rough, but working, implementation to add this functionality. I would be happy to open a pull request and get some feedback.

damonkelley avatar Nov 26 '14 20:11 damonkelley

@damonkelley, I will be glad to review your pull request.

chibisov avatar Nov 26 '14 20:11 chibisov

guys, you seriously need to note this in your documentations with bold font! I've wasted some really precious hours trying to do this and now I'm seeing this. the error message doesn't help at all too: Could not resolve URL for hyperlinked relationship using view name "productfield-detail". You may have failed to include the related model in your API, or incorrectly configured the "lookup_field" attribute on this field. Please, note this in docs!

sazary avatar Mar 02 '15 17:03 sazary

Just found myself in the same situation as @sazary, so I second his suggestion of giving people the heads-up.

By the way, isn't #67 the root cause for this? It's hard to tell since the description is in Russian.

gnarea avatar May 15 '15 13:05 gnarea

Would be great if this could be fixed. I just spent an hour or two trying to figure out why I was getting the same error.

rrauenza avatar May 27 '15 21:05 rrauenza

Same here... It would be great to have such documentation.

jsenecal avatar Jun 09 '15 14:06 jsenecal

Ah, I have been getting the same error as @sazary and assumed it was to do with view namespaces or lookup_field (I am using lookup_field, which made it even more confusing!).

If I remove the HyperlinkedRelationshipFields from my Serializer, can ExtendedDefaultRouter work with lookup_field anyway? I am aiming to get URLs like: /api/locations/{location}/items/{itemname} (both models have a pk that isn't the name, but the item names are unique within each location, and the names are meaningful to users)

howardjones avatar Sep 09 '15 17:09 howardjones

I'm considering this feature to be included.

auvipy avatar Dec 01 '15 18:12 auvipy

this should be addressed after releasing 0.3.0 version

auvipy avatar Dec 01 '15 18:12 auvipy

So now that we are on version 3.3.0, and this ticket still open, do you plan to include this feature @auvipy ?

AncAinu avatar Mar 09 '16 16:03 AncAinu

contributions are welcome

auvipy avatar Mar 09 '16 18:03 auvipy

I'm busy with cleaning up the drf-extension codes from legacy codes.

auvipy avatar Mar 09 '16 18:03 auvipy

Any news about this?

mbaragiola avatar Oct 05 '16 22:10 mbaragiola

It's been a few years, is this still an active project?

0x000bff avatar Aug 11 '19 22:08 0x000bff

yes, it is. check the commit history

auvipy avatar Aug 15 '19 06:08 auvipy