Limit number of model instances to be created - django

前端 未结 6 1529
萌比男神i
萌比男神i 2020-12-02 20:36

I have model from which I only want to create one instance, and no more instances should be allowed.

Is this possible? I\'ve got a feeling that I\'ve seen this done

6条回答
  •  半阙折子戏
    2020-12-02 21:18

    I would override create() method on default manager, but as stated above, this won't guarantee anything in multi-threaded environment.

提交回复
热议问题