diff --git a/readthedocs/api/v3/serializers.py b/readthedocs/api/v3/serializers.py index 5b3361259ef..8ef11514ecb 100644 --- a/readthedocs/api/v3/serializers.py +++ b/readthedocs/api/v3/serializers.py @@ -526,7 +526,7 @@ class SubprojectCreateSerializer(FlexFieldsModelSerializer): child = serializers.SlugRelatedField( slug_field='slug', - queryset=Project.objects.all(), + queryset=Project.objects.none(), ) class Meta: @@ -545,6 +545,10 @@ def __init__(self, *args, **kwargs): super().__init__(*args, **kwargs) + user = self.context['request'].user + # TODO: Filter projects using project restrictions for subproject. + self.fields['child'].queryset = user.projects.all() + def validate_child(self, value): # Check the user is maintainer of the child project user = self.context['request'].user