Как создать собственные разрешения для сайта администратора Django ⇐ Python
-
Anonymous
Как создать собственные разрешения для сайта администратора Django
By default when I create a model Django gives permissions like
add/change/delete/view If I give any of the above permission to a specific user then that user can view all the objects from that model. But I want to show them only objects linked with foreign keys.
Let's Say,
I have a Book model
class Book(models.Model): title = models.CharField(max_length=100) author = models.ForeignKey( User, on_delete=models.CASCADE ) If I want to give authors permission, they can only view their linked books from the Django admin.
How can I do that?
Источник: https://stackoverflow.com/questions/727 ... admin-site
By default when I create a model Django gives permissions like
add/change/delete/view If I give any of the above permission to a specific user then that user can view all the objects from that model. But I want to show them only objects linked with foreign keys.
Let's Say,
I have a Book model
class Book(models.Model): title = models.CharField(max_length=100) author = models.ForeignKey( User, on_delete=models.CASCADE ) If I want to give authors permission, they can only view their linked books from the Django admin.
How can I do that?
Источник: https://stackoverflow.com/questions/727 ... admin-site