          if getattr(model_field, 'unique', False):
              validator = UniqueValidator(queryset=model_field.model._default_manager)
              kwargs['validators'] = kwargs.get('validators', []) + [validator]
  
      return kwargs
  
  
  def get_nested_relation_kwargs(relation_info):
 
</s> remove                 many_to_many = PrimaryKeyRelatedField(many=True, queryset=ManyToManyTargetModel.objects.all())
 </s> add                 many_to_many = PrimaryKeyRelatedField(allow_empty=False, many=True, queryset=ManyToManyTargetModel.objects.all()) </s> remove                 many_to_many = HyperlinkedRelatedField(many=True, queryset=ManyToManyTargetModel.objects.all(), view_name='manytomanytargetmodel-detail')
 </s> add                 many_to_many = HyperlinkedRelatedField(allow_empty=False, many=True, queryset=ManyToManyTargetModel.objects.all(), view_name='manytomanytargetmodel-detail')
        if to_many and not model_field.blank:
            kwargs['allow_empty'] = False
          if getattr(model_field, 'unique', False):
              validator = UniqueValidator(queryset=model_field.model._default_manager)
              kwargs['validators'] = kwargs.get('validators', []) + [validator]
        if to_many and not model_field.blank:
            kwargs['allow_empty'] = False
  
      return kwargs
  
  
  def get_nested_relation_kwargs(relation_info):
keep keep add keep keep keep keep keep
 Respect blank on many to many, and set allow_empty=False if it is not present. Closes #2804. 
rest_framework/utils/field_mapping.py