Django Rest Framework – Could not resolve URL for hyperlinked relationship using view name “user-detail”

Because it’s a HyperlinkedModelSerializer your serializer is trying to resolve the URL for the related User on your Bottle.
As you don’t have the user detail view it can’t do this. Hence the exception.

  1. Would not just registering the UserViewSet with the router solve your issue?
  2. You could define the user field on your BottleSerializer to explicitly use the UserSerializer rather than trying to resolve the URL. See the serializer docs on dealing with nested objects for that.

Leave a Comment