我有一個模型,Package
:設置對象權限,以便只有`owner`字段中指定的用戶才能修改對象?
class Package(models.Model):
VIP = models.BooleanField()
name = models.CharField(max_length=200)
contents = models.CharField(max_length=200)
owner = # a string, user name goes here
對於Package
任何特定實例(也就是數據庫的每一行),我想,只有其用戶名的用戶匹配owner
可以修改此情況下,通過管理界面。我怎樣才能做到這一點?
https://docs.djangoproject.com/en/1.8/topics/auth/customizing/#django.contrib.auth.models.PermissionsMixin – Gocht
@Gocht不知道如何解決我的問題? – becko
可以修改對象_how_?在管理員?通過ORM?使用網頁表單?你需要具體。 –