Skip to content

Browsable API can't resolve URLs for HyperlinkedRelatedFields when using namespaced versioning #2489

Closed
@brandoncazander

Description

@brandoncazander

My POST requests to a ModelViewSet using a HyperlinkedModelSerializer don't work due to HyperlinkedRelatedField.to_internal_value() failing with

ValidationError: [u'Invalid hyperlink - Incorrect URL match.']

This is using NamespaceVersioning, and the failure originates at line 225 of relations.py since match.view_name = 'v1:snippet-detail' but self.view_name = 'snippet-detail'.

I have a failing unit test for this but can't decide how to best solve it. When we reverse URLs, if a versioning scheme is in place then the scheme's reverse function handles it (in particular, NamespaceVersioning.reverse() adds on the version to the view name).

Is there a way to get at the request from the HyperlinkedRelatedField? If I can get pointed in the right direction then I'll make up a pull request for this.

Thanks!

Metadata

Metadata

Assignees

No one assigned

    Labels

    Type

    No type

    Projects

    No projects

    Milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions