Make a Django model read-only? -
what says on tin. there way make django model read-only?
by mean django model in once records have been created, can't edited.
this useful model records transaction history.
you can override model's save method , check whether it's existing entity, in case won't save changes:
def save(self, *args, **kwargs): if self.id none: super(modelname, self).save(*args, **kwargs)
so in example save changes when entity has not got id
yet, case when it's new entity hasn't been inserted yet.
Comments
Post a Comment