开发者

Django admin - Keep updating a model and do not create more than one

Im not sure how to put this title. But what I need is a simple model that I can just update everytime. Lets say I have a Settings model ,and these settings I just want to update or cha开发者_如何学Pythonnge every now and again. So there is no need to add another object to that model.

Is there suck a field or type of admin-model that I can use?

I could otherwise just keep updating the same object, but I do not want the user to be able to just "Add Setting".


in admin you can specify various permissions. to remove the "add" functionality:

class MyModelAdmin(admin.ModelAdmin):
    def has_add_permission(self, request): return False
make sure you create your first and only settings object when you deploy the application.

here is a discussion about singleton models in django: How about having a SingletonModel in Django?

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜