I have two models: where
class Hunter(Model):
name = CharField()
searches for
class Target(Model):
name = CharField()
user = ForeignKey(User)
approved_hunters = ManyToManyField(Hunter)
my serializers are
class AnonymousTargetSerializer(ModelSerializer):
class Meta:
name = 'target'
model = Target
fields = ['id',]
and also
class TargetSerializer(ModelSerializer):
class Meta:
name = 'target'
model = Target
fields = ['id',]
Im my viewsets I would like to:
hunter = Hunter.objects.get(user=self.request.user)
if hunter in Target.approved_hunters.all()
return TagetSerializer
else:
return AnonymousTargetSerializer
However I only seem to get this done for the viewset, but cannot filter on an individual object level.