def __init__(self, *args, **kwargs):
        super(DatabaseSerializer, self).__init__(*args, **kwargs)

        request = self.context.get('request', None)
        if request:
            creating = request.method == 'POST'

            # when database is created, user can't change plan, environment and
            # name
            self.fields['plan'].read_only = not creating
            self.fields['environment'].read_only = not creating
            self.fields['name'].read_only = not creating
            self.fields['credentials'].read_only = True
            self.fields['description'].read_only = not creating

        # quarantine is always readonly
        # self.fields['quarantine_dt'].read_only = True
dataset/ETHPy150Open globocom/database-as-a-service/dbaas/api/database.py/DatabaseSerializer.__init__/original