Note that there are some explanatory texts on larger screens.

plurals
  1. PO
    text
    copied!<p>In short, yes, you're ok.</p> <p>Because:</p> <p>1) Using AUTH_PROFILE_MODULE=Employee will make Employee instance to be available for instance in this way:</p> <pre><code>def view(request): employee_instance = request.user.get_profile() </code></pre> <p>2) Using custom permissions is easy, see: <a href="https://docs.djangoproject.com/en/dev/topics/auth/#custom-permissions" rel="nofollow">https://docs.djangoproject.com/en/dev/topics/auth/#custom-permissions</a></p> <p>Edit:</p> <p>having custom permissions on organizations is possible as well, probably best if you create permissions programatically, like mentioned in the manual, this way:</p> <pre><code>content_type = ContentType.objects.get(app_label='myapp', model='Organization') permission = Permission.objects.create(codename='can_do_something', name='Can Do something', content_type=content_type) </code></pre> <p>now, you have permission aware organization model, you just assign it to your user.</p> <p>To clarify more:</p> <p>Django auth system is sort of a fixed ACL. You assign roles to a user (or group) and that's pretty much it. Django offers helper wrapper function to easily filter out users who don't have a given permission. If you need to decide at runtime and/or in more generic way, whether an object has permission to do something, you either need full blown ACL system (and which django.auth is not) or you code that kind of behavior yourself. This depends on your needs and obviously on the need to manage those permissions. In the OP's case, the behavior is fixed, therefore I would recommend just coding this in and be happy. But the needs may vary and so does the solution. Django auth is good at assigning static permissions to user, gropu or a "profile" object. What that means to your app is up to you in the end.</p> <p>So in this case, the good solution would be to have a fixed set of permissions like "can view own documents" or "can view organization documents" that is assigned to user/group. And you app should decide, what it means and serve documents accordingly, taking either runtime state in the account or using models structure to determine the proper data set to serve.</p>
 

Querying!

 
Guidance

SQuiL has stopped working due to an internal error.

If you are curious you may find further information in the browser console, which is accessible through the devtools (F12).

Reload