You probably want to use a relational field (PrimaryKeyRelatedField or similar) and modify the query set used for it within your init method of your serializer. You should have access to the current request through the serializer context, and you can use it for filtering down the values accepted by your field.
On Tue, Aug 16, 2016, 11:43 Jenna Pullen <[email protected]> wrote: > Hi Guys, > > I am having difficulty figuring out how to filter my fields choices by the > logged in User. Does anyone know how this works? > > question = > serializers.ChoiceField(choices=Question.objects.filter(user=serializers.CurrentUserDefault())) > # tried > > Thanks > > -- > You received this message because you are subscribed to the Google Groups > "Django REST framework" group. > To unsubscribe from this group and stop receiving emails from it, send an > email to [email protected]. > For more options, visit https://groups.google.com/d/optout. > -- You received this message because you are subscribed to the Google Groups "Django REST framework" group. To unsubscribe from this group and stop receiving emails from it, send an email to [email protected]. For more options, visit https://groups.google.com/d/optout.
