Skip to content

Commit

Permalink
Fixed clear computer.tags through DRF (encode/django-rest-framework#2883
Browse files Browse the repository at this point in the history
)
  • Loading branch information
jact committed Jun 4, 2018
1 parent 1035840 commit 3c80f91
Show file tree
Hide file tree
Showing 2 changed files with 9 additions and 1 deletion.
8 changes: 8 additions & 0 deletions migasfree/server/serializers.py
Original file line number Diff line number Diff line change
Expand Up @@ -97,6 +97,14 @@ class Meta:


class ComputerWriteSerializer(serializers.ModelSerializer):
def is_valid(self, raise_exception=False):
data = self.get_initial()
if data.get('tags')[0] == '':
self.instance.tags.clear()
del self.fields['tags']

return super(ComputerWriteSerializer, self).is_valid(raise_exception)

class Meta:
model = models.Computer
fields = (
Expand Down
2 changes: 1 addition & 1 deletion migasfree/server/static/js/computer_change_form.js
Original file line number Diff line number Diff line change
Expand Up @@ -13,7 +13,7 @@ $(function(){
return (x !== (undefined || null || ""));
});

return tmp.map(Number);
return (tmp.length > 0) ? tmp.map(Number) : null;
};

$.ajaxSetup({
Expand Down

0 comments on commit 3c80f91

Please sign in to comment.