Skip to content
Snippets Groups Projects
Commit 5f46debf authored by rlacko's avatar rlacko
Browse files

String null to empty string in JSON

parent 82ad93fb
Branches
Tags
1 merge request!2Dev
......@@ -14,6 +14,11 @@ class DocumentSerializer(serializers.ModelSerializer):
model = models.Document
fields = ('uploaded_by', 'uploaded_at', 'name', 'description', 'file', 'uploaded_by_name', 'solution', )
def to_representation(self, instance):
data = super().to_representation(instance)
if not data['file']: data['file']= ""
return data
def get_uploaded_by_name(self, obj):
return obj.uploaded_by.full_name
......
......@@ -37,6 +37,13 @@ class NoteSerializer(serializers.ModelSerializer):
created_by = serializers.HiddenField(default=CurrentUserProfileDefault())
created_by_name = serializers.SerializerMethodField()
def to_representation(self, instance):
data = super().to_representation(instance)
if not data['event']: data['event']= ""
if not data['profile']: data['profile']= ""
return data
class Meta:
model = models.Note
fields = '__all__'
......
0% Loading or .
You are about to add 0 people to the discussion. Proceed with caution.
Please register or to comment