Remove uneditable Instance fields from API browser

This commit is contained in:
Alan Rominger 2022-12-06 15:20:04 -05:00
parent adbcb5c5e4
commit 4a7f4d0ed4
No known key found for this signature in database
GPG Key ID: C2D7EAAA12B63559

View File

@ -344,6 +344,13 @@ class InstanceDetail(RetrieveUpdateAPIView):
model = models.Instance
serializer_class = serializers.InstanceSerializer
def update_raw_data(self, data):
# these fields are only valid on creation of an instance, so they unwanted on detail view
data.pop('listener_port', None)
data.pop('node_type', None)
data.pop('hostname', None)
return super(InstanceDetail, self).update_raw_data(data)
def update(self, request, *args, **kwargs):
r = super(InstanceDetail, self).update(request, *args, **kwargs)
if status.is_success(r.status_code):