Is there a clean way to hide model attributes from some users in Django?
<p>I'm trying to introduce field-level permissions in my app that would effectively hide/nullify model field values from some users, while showing them to others.  A user would need to be able to do something like this:</p>

<pre><code>class MyRestrictedModel(HypotheticalMixin, models.Model):
    public = CharField(max_length=128)
    restricted = RestrictedCharField(
        max_length=128,
        permitted_groups=("group1",)
    )

user1 = User.objects.get(pk=1)  # in group1
user2 = User.objects.get(pk=2)  # NOT in group 1

model_instance1 = MyRestrictedModel.objects.get(pk=1).restrict(user1)
model_instance2 = MyRestrictedModel.objects.get(pk=1).restrict(user2)

print(model_instance1.public)  # "this is public data"
print(model_instance1.restricted)  # "this is restricted data"

print(model_instance2.public)  # "this is public data"
print(model_instance2.restricted)  # None
</code></pre>

<p>I think I might be able to hack something together to get this working, but I'd hate to do that work if something more robust and community-accepted was available, so I thought I'd ask here.  Does such a thing exist?</p>