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:
make sure you create your first and only settings object when you deploy the application.
class MyModelAdmin(admin.ModelAdmin):
def has_add_permission(self, request): return False
here is a discussion about singleton models in django: How about having a SingletonModel in Django?
精彩评论