How can I make a Django model read-only?

后端 未结 3 1702
后悔当初
后悔当初 2021-02-01 19:47

Is it possible to make a Django model read only? No creating, updating etc.

N.B. this question is different to:

Make a Django model read-only? (this question all

3条回答
  •  Happy的楠姐
    2021-02-01 20:36

    Override the save and delete methods for the model. How are you planning to add objects to your model?

    def save(self, *args, **kwargs):
         return
    
    def delete(self, *args, **kwargs):
         return
    

提交回复
热议问题