[Answer]-Best way to forbidden access on object of other user in django;

1๐Ÿ‘

โœ…

I usually create a @owner_required decorator to wrap elements with such requirements, how the logic works depends on usecase

0๐Ÿ‘

You should have an association in your user model, and then in you controllers you should do all object access through your user model associations, so each user can only access each own childs. Here is a related post How to create new (unsaved) Django model with associations?

๐Ÿ‘คryudice

0๐Ÿ‘

If you need more granular security than what Django provides out-of-the-box then you might want to look into one of the ACL offerings. Starting with Django 1.2 it is possible to add object/row level permissions using a third-party plugin. There are several to choose from. See this SO question for suggestions:

Django 1.2 object level permissions โ€“ third party solutions?

๐Ÿ‘คDaniel Eriksson

Leave a comment