You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
I'm trying to figure out how to put links on objects to actions with this extension.
With DRF without any other extensions I'm able to use HyperlinkedIdentityField in the serializer to add the link to a view as can be seen in the following code and screenshot of output json.
from rest_framework.viewsets import ModelViewSet
from rest_framework.relations import HyperlinkedIdentityField
from rest_framework.serializers import HyperlinkedModelSerializer
class ActivityListSet(ModelViewSet):
queryset = Activity.objects.all()
serializer_class = ActivitySerializer
@action(detail=True)
def geojson(self, request, pk=None):
return Response({"a": "test"})
class ActivitySerializer(HyperlinkedModelSerializer):
geo_json = HyperlinkedIdentityField(
view_name="activity-geojson"
)
class Meta:
model = Activity
fields = [
"self",
"status",
"error",
"started_at",
"completed_at",
"geo_json"
]
However once switching over to use the DRF Json API equivalent (HyperlinkedIndentityField does not seem to exist) I'm getting the following error: type object 'Activity' has no attribute 'geo_json'
I've searched through the issues in the project as well as the documentation, but I'm unable to find out why this does not work with this extension. DRF also has an example with a similar use case as mine, so it seems like I'm using HyperlinkedIdentityField as intended
Would greatly appreciate if anyone can help me figure out how to solve this issue
The text was updated successfully, but these errors were encountered:
Thanks for your report. It could be that the support for HyperlinkedIdentityField is not complete. Could you provide an exception stacktrace?
If you have more time at hand best actually would be if you could provide a test which reproduces this issue within the test framework of DJA. There are tests for plain DRF classes support and there is a test for HyperlinkedIdentityField already. Somehow your use case seems to be different though.
Hi
I'm trying to figure out how to put links on objects to actions with this extension.
With DRF without any other extensions I'm able to use HyperlinkedIdentityField in the serializer to add the link to a view as can be seen in the following code and screenshot of output json.
However once switching over to use the DRF Json API equivalent (HyperlinkedIndentityField does not seem to exist) I'm getting the following error:
type object 'Activity' has no attribute 'geo_json'
I've searched through the issues in the project as well as the documentation, but I'm unable to find out why this does not work with this extension. DRF also has an example with a similar use case as mine, so it seems like I'm using
HyperlinkedIdentityField
as intendedWould greatly appreciate if anyone can help me figure out how to solve this issue
The text was updated successfully, but these errors were encountered: