Inheriting Permissions from Abstract Class

34 views
Skip to first unread message

Alec Koumjian

unread,
Jan 24, 2012, 4:39:18 PM1/24/12
to django...@googlegroups.com
I have some custom permissions that I would like to give to about half a dozen different classes. If I did them individually they might look like this:

MyModel(models.Model):
...
    Meta:
        permissions = (('view_mymodel', 'View Mymodel'),)
        ...

That's all good and well, but following a DRY principle, I thought I would simply create an abstract class to inherit from. I thought it would look like this:

MyAbstractModel(models.Model):
...
    Meta:
        permissions = (('view_%s' % self.__class__, 'View %s' % self.__class__))
        ...

MyModel(MyAbstractModel):
...

The problem is that, as far as I can tell, there is no way to access the class name from inside the Meta class. I can't find a way to make the above work. I'm very much looking for suggestions.

Alec Koumjian

unread,
Jan 27, 2012, 2:51:52 PM1/27/12
to django...@googlegroups.com
Just wanted to ping this as it just got approved.
Reply all
Reply to author
Forward
0 new messages