4👍
Right now, you are passing a model instance rather than the originating request in your serializer.
I suspect you need to instead pass the request via the context in the first serializer call (in your ListAPIView) then access it via self.context in your serializer class. See here. This will let you use the request data to build the uri (and avoid the “No attribute” error you have right now, because you will be passing the kind of object that method expects).
This involves overriding the methods declared here and here in your ListAPIView.
2👍
By looking at the traceback, it seems you are doing something wrong in the get_url()
function which you have overridden in your serializers.py
.
According to DRF docs,
This method should return the URL that corresponds to the given
object.
Basic signature of DRF reverse() function:
def reverse(viewname, args=None, kwargs=None, request=None, format=None, **extra):
You must pass the proper values for the arguments as defined in reverse()
. The error might be arising due to incorrect values being sent to reverse()
function.
- [Django]-Serialization to JSON two querysets in Django
- [Django]-Django editing in place
- [Django]-How do I treat django's TemporaryUploadedFile as a regular python file
- [Django]-Give a bytes to reportlab.lib.utils.ImageReader
- [Django]-Custom filtering in django rest framework