Hi Ive been using the following with no issues for months, to set the default user and allow it to be sent out in the get requests:
class FileSerializer(serializers.ModelSerializer): uploaded_by = serializers.PrimaryKeyRelatedField( read_only=True, default=serializers.CurrentUserDefault() ) class Meta: model = File fields = ... Its used in a basic ModelViewSet and the uploaded_by is not part of any unique validators, it just required. I just want to check it this is still ok to do this as the uploaded_by is correctly in the serializers data but is missing from the validated_data when its reported as being valid. Then the save attempt as expected wines with IntegrityError: null value in column "uploaded_by_id" violates not-null constraint. I can see that there was a unique together validation went in 3.8.2 for read_only + default. Im guessing this is the cause but wanted to check what im doing is still sensible. Cheers Stu -- 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 django-rest-framework+unsubscr...@googlegroups.com. For more options, visit https://groups.google.com/d/optout.