self.view_args[fields[0]] = fields[1] if len(fields) > 1 else fields[0]
def to_representation(self, value):
self.view_args[fields[0]] = fields[1] if len(fields) > 1 else fields[0]
def to_representation(self, value):
if self.view_name is not None:
kwargs = {
arg: getattr(value, field)
for (arg, field) in self.view_args.items()
}
if self.view_name is not None:
kwargs = {
arg: getattr(value, field)
for (arg, field) in self.view_args.items()
}
- value = reverse(self.view_name, kwargs=kwargs)
- return self.context['request'].build_absolute_uri(value)
+ return reverse(self.view_name, kwargs=kwargs, request=request)
+ return request.build_absolute_uri(value)