On 14 déc, 15:26, Yanik <yanikpro...@gmail.com> wrote: > Hello, > > I need to build a custom ACL for the app I'm working on, Django's > isn't specific enough (I need to give permissions based on IDs, > statuses, etc.). > > I'd also like to attach it to the user, so that I could lookup in a > way something like User.acl.has_permission(post_id, "can_edit). How > can I attach my ACL to the User model "dynamically", without actually > touching Django's base code?
if 'ACL' is a model (I mean, a django.db.models.Model subclass), then just add a foreign key to the User model: from django.db import models from django.contrib.auth import User class ACL(models.Model): user = models.ForeignKey(User, related_name='acl') ... Else, you can always monkeypatch the User model. You may then want to use the descriptor protocol (http://docs.python.org/reference/ datamodel.html#descriptors) HTH --~--~---------~--~----~------------~-------~--~----~ You received this message because you are subscribed to the Google Groups "Django users" group. To post to this group, send email to django-users@googlegroups.com To unsubscribe from this group, send email to django-users+unsubscr...@googlegroups.com For more options, visit this group at http://groups.google.com/group/django-users?hl=en -~----------~----~----~----~------~----~------~--~---