سؤال

I quote from the documentation:

"Permissions can be set not only per type of object, but also per specific object instance. By using the has_add_permission(), has_change_permission() and has_delete_permission() methods provided by the ModelAdmin class, it is possible to customize permissions for different object instances of the same type."

https://docs.djangoproject.com/en/1.5/topics/auth/default/

I can't find any info about how to set this up. I want users to only be able to change instances of a model which they are attached to, not all instances of that model.

هل كانت مفيدة؟

المحلول

That refers to the Django admin. Here's how you define an admin model:

https://docs.djangoproject.com/en/1.5/ref/contrib/admin/#django.contrib.admin.ModelAdmin

And here's how you define permissions:

https://docs.djangoproject.com/en/1.5/ref/contrib/admin/#django.contrib.admin.ModelAdmin.has_add_permission

(I asssumed you're using Django 1.5, and not the latest, 1.6.2)

مرخصة بموجب: CC-BY-SA مع الإسناد
لا تنتمي إلى StackOverflow
scroll top