Closed pmg103 closed 4 years ago
Looks good. I idly wonder whether this sort of thing is so common (ie you almost always want a list of things that are visible to the current user) then maybe there'd be a nicer way to do this declaritively: created_by=LazyRequestUser()
or CurrentUserFilter(field="created_by")
or something. But I have no idea how this would be implemented and it sounds complicated.
Right yeah you could just have a placeholder for RequestUser
that would get handled specially in the logic. Could take that approach instead. Pros and cons I guess. I went with something that felt very DRF-esque.
If the
serialization_spec
is to depend on a runtime value (such asself.request.user
) then allow it to be specified in aget_serialization_spec()
method.Addresses https://github.com/dabapps/django-rest-framework-serialization-spec/issues/37